]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1, Fix EDKT141
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 29 Jul 2006 14:29:59 +0000 (14:29 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 29 Jul 2006 14:29:59 +0000 (14:29 +0000)
2, Code clean up for PCD building tools.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1150 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
Tools/Source/GenBuild/org/tianocore/build/pcd/entity/DynamicTokenValue.java
Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java
Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java
Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java

index 366e0ac59d98de60400444fce8d63ceff549e82a..a8ec270355146dd8693d376a193171900050f649 100644 (file)
@@ -456,25 +456,18 @@ public class AutoGen {
                GuidGuidToAutogenC(fileBuffer);\r
 \r
                //\r
-               // Call pcd autogen. PCDAutoGenAction tool only need module name and\r
-               // isPcdEmulatedDriver as parameter. Library inherits PCD and module's\r
-               // PCD information has been collected in FPDParser task by\r
-               // CollectPCDAction.\r
-               // Note : when PCD image tool ready,\r
-               // isPCDEmulatedDriver parameter will be removed.\r
-               //\r
-                try {\r
-//              this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),\r
-//              moduleId.getGuid(), moduleId.getPackage().getName(), moduleId.getPackage().getGuid(),this.arch,moduleId.getVersion(),false, null);\r
-         this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),null,null,null, this.arch,null,false, null);\r
-                this.myPcdAutogen.execute();\r
-                } catch (Exception e) {\r
-                throw new BuildException("PCD Autogen failed:" + e.getMessage());\r
-                }\r
+               // Call pcd autogen. \r
+               //\r
+                this.myPcdAutogen = new PCDAutoGenAction(moduleId, this.arch, false, null);\r
+                try {\r
+                    this.myPcdAutogen.execute();\r
+                } catch (Exception exp) {\r
+                    throw new BuildException (exp.getMessage());\r
+                }\r
                \r
                if (this.myPcdAutogen != null) {\r
-            fileBuffer.append("\r\n");\r
-                       fileBuffer.append(this.myPcdAutogen.OutputC());\r
+                    fileBuffer.append("\r\n");\r
+                    fileBuffer.append(this.myPcdAutogen.OutputC());\r
                }\r
 \r
                if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
@@ -613,33 +606,21 @@ public class AutoGen {
                fileBuffer.append("\r\n");\r
 \r
                //\r
-               // Call pcd autogen. PCDAutoGenAction tool only need module name and\r
-               // isPcdEmulatedDriver as parameter. Library inherit PCD and module's\r
-               // PCD information has been collected in FPDParser task by\r
-               // CollectPCDAction.\r
-               // Note : when PCD image tool ready,\r
-               // isPCDEmulatedDriver parameter will be removed.\r
+               // Call pcd autogen. \r
                //\r
+                this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,\r
+                                                         this.arch,\r
+                                                         true, \r
+                                                         SurfaceAreaQuery.getModulePcdEntryNameArray());\r
                try {\r
-//                      this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),\r
-//                      this.moduleId.getGuid(),moduleId.getPackage().getName(),moduleId.getPackage().getGuid(), this.arch, moduleId.getVersion(),true, SurfaceAreaQuery.getModulePcdEntryNameArray());\r
-            this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),\r
-                                                     null,\r
-                                                     null,\r
-                                                     null,\r
-                                                     this.arch,\r
-                                                     null,\r
-                                                     true, \r
-                                                     SurfaceAreaQuery.getModulePcdEntryNameArray());\r
-                     \r
-                       this.myPcdAutogen.execute();\r
+                    this.myPcdAutogen.execute();\r
                } catch (Exception e) {\r
-                       throw new BuildException(e.getMessage());\r
+                    throw new BuildException(e.getMessage());\r
                }\r
 \r
                if (this.myPcdAutogen != null) {\r
-            fileBuffer.append("\r\n");\r
-                       fileBuffer.append(this.myPcdAutogen.OutputC());\r
+                    fileBuffer.append("\r\n");\r
+                    fileBuffer.append(this.myPcdAutogen.OutputC());\r
                }\r
 \r
                if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
index 18b766dc422967284e08ade8e70d6bce04334464..a769816720f39c4b948cd82f05cbe4c0a2c0044e 100644 (file)
@@ -807,8 +807,8 @@ public class GlobalData {
     //\r
     // For PCD\r
     //\r
-    public synchronized static Map<FpdModuleIdentification, XmlObject> getFpdModuleSaXmlObject(\r
-            String xmlObjectName) {\r
+    public synchronized static Map<FpdModuleIdentification, XmlObject> \r
+                               getFpdModuleSaXmlObject(String xmlObjectName) {\r
         Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();\r
         Iterator item = fpdModuleSASet.iterator();\r
         \r
@@ -823,17 +823,20 @@ public class GlobalData {
             try{\r
                 if (SANode.get(xmlObjectName)!= null){\r
                     SAPcdBuildDef.put(moduleId,\r
-                            (XmlObject) SANode\r
-                                    .get(xmlObjectName));\r
+                            (XmlObject) SANode.get(xmlObjectName));\r
 \r
                 }\r
-                            \r
-                \r
             } catch (Exception e){\r
                 EdkLog.log(EdkLog.EDK_INFO, e.getMessage());\r
             }\r
-            }\r
+        }\r
         return SAPcdBuildDef;\r
     }\r
+\r
+    public synchronized static Map<FpdModuleIdentification,XmlObject> getFpdPcdBuildDefinitions() {\r
+        Map<FpdModuleIdentification,XmlObject> pcdBuildDef = getFpdModuleSaXmlObject ("PcdBuildDefinition");\r
+\r
+        return pcdBuildDef;\r
+    }\r
 }\r
 \r
index 4d3aadd9619a3f91116e6473bae15c27de76e478..8242a4c87c363dca42b14fbc237c6a635f683b38 100644 (file)
@@ -1124,7 +1124,7 @@ class PcdDatabase {
             if (t.isDynamicEx()) {\r
                 exMapTable.add((int)t.tokenNumber, \r
                                 t.dynamicExTokenNumber, \r
-                                guidTable.add(t.tokenSpaceName, t.getPrimaryKeyString()), \r
+                                guidTable.add(translateSchemaStringToUUID(t.tokenSpaceName), t.getPrimaryKeyString()), \r
                                 t.getPrimaryKeyString()\r
                                 );\r
             }\r
@@ -1387,7 +1387,7 @@ class PcdDatabase {
     }\r
     \r
     private String getDataTypeDeclarationForVariableDefault (Token token, String cName, int skuId) \r
-    throws EntityException {\r
+        throws EntityException {\r
 \r
         String typeStr;\r
 \r
@@ -1565,28 +1565,119 @@ class PcdDatabase {
         return retStr;\r
     }\r
 \r
+    /**\r
+       Translate the schema string to UUID instance.\r
+       \r
+       In schema, the string of UUID is defined as following two types string:\r
+        1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(\r
+        )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?\r
+       \r
+        2) GuidNamingConvention: pattern =\r
+        [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\r
+       \r
+       This function will convert string and create uuid instance.\r
+       \r
+       @param uuidString    UUID string in XML file\r
+       \r
+       @return UUID         UUID instance\r
+    **/\r
+    private UUID translateSchemaStringToUUID(String uuidString) \r
+        throws EntityException {\r
+        String      temp;\r
+        String[]    splitStringArray;\r
+        int         index;\r
+        int         chIndex;\r
+        int         chLen;\r
+\r
+        if (uuidString == null) {\r
+            return null;\r
+        }\r
+\r
+        if (uuidString.length() == 0) {\r
+            return null;\r
+        }\r
+\r
+        if (uuidString.equals("0") ||\r
+            uuidString.equalsIgnoreCase("0x0")) {\r
+            return new UUID(0, 0);\r
+        }\r
+\r
+        uuidString = uuidString.replaceAll("\\{", "");\r
+        uuidString = uuidString.replaceAll("\\}", "");\r
+\r
+        //\r
+        // If the UUID schema string is GuidArrayType type then need translate \r
+        // to GuidNamingConvention type at first.\r
+        // \r
+        if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {\r
+            splitStringArray = uuidString.split("," );\r
+            if (splitStringArray.length != 11) {\r
+                throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString);\r
+            }\r
+\r
+            //\r
+            // Remove blank space from these string and remove header string "0x"\r
+            // \r
+            for (index = 0; index < 11; index ++) {\r
+                splitStringArray[index] = splitStringArray[index].trim();\r
+                splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length());\r
+            }\r
+\r
+            //\r
+            // Add heading '0' to normalize the string length\r
+            // \r
+            for (index = 3; index < 11; index ++) {\r
+                chLen = splitStringArray[index].length();\r
+                for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) {\r
+                    splitStringArray[index] = "0" + splitStringArray[index];\r
+                }\r
+            }\r
+\r
+            //\r
+            // construct the final GuidNamingConvention string\r
+            // \r
+            temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",\r
+                                 splitStringArray[0],\r
+                                 splitStringArray[1],\r
+                                 splitStringArray[2],\r
+                                 splitStringArray[3],\r
+                                 splitStringArray[4],\r
+                                 splitStringArray[5],\r
+                                 splitStringArray[6],\r
+                                 splitStringArray[7],\r
+                                 splitStringArray[8],\r
+                                 splitStringArray[9],\r
+                                 splitStringArray[10]);\r
+            uuidString = temp;\r
+        }\r
+\r
+        return UUID.fromString(uuidString);\r
+    }\r
 }\r
 \r
+/** Module Info class is the data structure to hold information got from GlobalData.\r
+*/\r
 class ModuleInfo {\r
-    private String                  type;\r
-    private FpdModuleIdentification moduleId;\r
+    ///\r
+    /// Module's ID for a <ModuleSA>\r
+    /// \r
+    private FpdModuleIdentification                       moduleId;\r
+    ///\r
+    /// <PcdBuildDefinition> xmlobject in FPD file for a <ModuleSA>\r
+    /// \r
     private PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef;\r
-    \r
-    \r
 \r
-    public ModuleInfo (FpdModuleIdentification moduleId, String type, XmlObject pcdDef) {\r
-        this.moduleId = moduleId;\r
-        this.type   = type;\r
-        this.pcdBuildDef = ((PcdBuildDefinitionDocument)pcdDef).getPcdBuildDefinition();\r
-    }\r
-    public String getModuleType (){\r
-       return this.type;\r
+    public ModuleInfo (FpdModuleIdentification moduleId, XmlObject pcdDef) {\r
+        this.moduleId       = moduleId;\r
+        this.pcdBuildDef    = ((PcdBuildDefinitionDocument)pcdDef).getPcdBuildDefinition();\r
     }\r
+\r
     public FpdModuleIdentification getModuleId (){\r
-       return this.moduleId;\r
+       return moduleId;\r
     }\r
+\r
     public PcdBuildDefinitionDocument.PcdBuildDefinition getPcdBuildDef(){\r
-       return this.pcdBuildDef;\r
+       return pcdBuildDef;\r
     }\r
 }\r
 \r
@@ -1595,22 +1686,29 @@ class ModuleInfo {
     from buildAction or UIAction.\r
 **/\r
 public class CollectPCDAction {\r
+    ///\r
     /// memoryDatabase hold all PCD information collected from SPD, MSA, FPD.\r
+    /// \r
     private MemoryDatabaseManager dbManager;\r
-\r
+    ///\r
     /// Workspacepath hold the workspace information.\r
+    /// \r
     private String                workspacePath;\r
-\r
+    ///\r
     /// FPD file is the root file. \r
+    /// \r
     private String                fpdFilePath;\r
-\r
+    ///\r
     /// Message level for CollectPCDAction.\r
+    /// \r
     private int                   originalMessageLevel;\r
-\r
+    ///\r
     /// Cache the fpd docment instance for private usage.\r
+    /// \r
     private PlatformSurfaceAreaDocument fpdDocInstance;\r
-    \r
+    ///\r
     /// xmlObject name\r
+    /// \r
     private static String xmlObjectName = "PcdBuildDefinition"; \r
        \r
     /**\r
@@ -1697,8 +1795,7 @@ public class CollectPCDAction {
         createTokenInDBFromFPD();\r
         \r
         //\r
-        // Call Private function genPcdDatabaseSourceCode (void); ComponentTypeBsDriver\r
-        // 1) Generate for PEI, DXE PCD DATABASE's definition and initialization.\r
+        // Generate for PEI, DXE PCD DATABASE's definition and initialization.\r
         //\r
         genPcdDatabaseSourceCode ();\r
         \r
@@ -1713,7 +1810,7 @@ public class CollectPCDAction {
     **/\r
     private void genPcdDatabaseSourceCode()\r
         throws EntityException {\r
-        String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions ();\r
+        String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions();\r
 \r
         ArrayList<Token> alPei = new ArrayList<Token> ();\r
         ArrayList<Token> alDxe = new ArrayList<Token> ();\r
@@ -1721,17 +1818,14 @@ public class CollectPCDAction {
         dbManager.getTwoPhaseDynamicRecordArray(alPei, alDxe);\r
         PcdDatabase pcdPeiDatabase = new PcdDatabase (alPei, "PEI", 0);\r
         pcdPeiDatabase.genCode();\r
-        MemoryDatabaseManager.PcdPeimHString        = PcdCommonHeaderString + pcdPeiDatabase.getHString()\r
-                                            + PcdDatabase.getPcdPeiDatabaseDefinitions();\r
+        MemoryDatabaseManager.PcdPeimHString        = PcdCommonHeaderString + pcdPeiDatabase.getHString() + \r
+                                                      PcdDatabase.getPcdPeiDatabaseDefinitions();\r
         MemoryDatabaseManager.PcdPeimCString        = pcdPeiDatabase.getCString();\r
 \r
-        PcdDatabase pcdDxeDatabase = new PcdDatabase (alDxe, \r
-                                                      "DXE",\r
-                                                      alPei.size()\r
-                                                      );\r
+        PcdDatabase pcdDxeDatabase = new PcdDatabase(alDxe, "DXE", alPei.size());\r
         pcdDxeDatabase.genCode();\r
-        MemoryDatabaseManager.PcdDxeHString   = MemoryDatabaseManager.PcdPeimHString + pcdDxeDatabase.getHString()\r
-                                      + PcdDatabase.getPcdDxeDatabaseDefinitions();\r
+        MemoryDatabaseManager.PcdDxeHString   = MemoryDatabaseManager.PcdPeimHString + pcdDxeDatabase.getHString() + \r
+                                                PcdDatabase.getPcdDxeDatabaseDefinitions();\r
         MemoryDatabaseManager.PcdDxeCString   = pcdDxeDatabase.getCString();\r
     }\r
 \r
@@ -1745,30 +1839,23 @@ public class CollectPCDAction {
      */\r
     private List<ModuleInfo> getComponentsFromFPD() \r
         throws EntityException {\r
-        List<ModuleInfo>            allModules  = new ArrayList<ModuleInfo>();\r
-        ModuleInfo                  current     = null;\r
-        int                         index       = 0;\r
-        FrameworkModulesDocument.FrameworkModules fModules = null;\r
-        ModuleSADocument.ModuleSA[]               modules  = null;\r
-        HashMap<String, XmlObject>                map      = new HashMap<String, XmlObject>();\r
-\r
-        if (fpdDocInstance == null) {\r
-            try {\r
-                fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath));\r
-            } catch(IOException ioE) {\r
-                throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());\r
-            } catch(XmlException xmlE) {\r
-                throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());\r
-            }\r
+        List<ModuleInfo>                            allModules          = new ArrayList<ModuleInfo>();\r
+        FrameworkModulesDocument.FrameworkModules   fModules            = null;\r
+        ModuleSADocument.ModuleSA[]                 modules             = null;\r
+        Map<FpdModuleIdentification, XmlObject>     pcdBuildDefinitions = null;\r
 \r
+        pcdBuildDefinitions = GlobalData.getFpdPcdBuildDefinitions();\r
+        if (pcdBuildDefinitions == null) {\r
+            return null;\r
         }\r
 \r
-        Map<FpdModuleIdentification,XmlObject>pcdBuildDef = GlobalData.getFpdModuleSaXmlObject(CollectPCDAction.xmlObjectName);\r
-        Set<FpdModuleIdentification> pcdBuildKeySet = pcdBuildDef.keySet();\r
-        Iterator item = pcdBuildKeySet.iterator();\r
+        //\r
+        // Loop map to retrieve all PCD build definition and Module id \r
+        // \r
+        Iterator item = pcdBuildDefinitions.keySet().iterator();\r
         while (item.hasNext()){\r
-            FpdModuleIdentification id = (FpdModuleIdentification)item.next();\r
-            allModules.add(new ModuleInfo(id, id.getModule().getModuleType(),pcdBuildDef.get(id)));    \r
+            FpdModuleIdentification id = (FpdModuleIdentification) item.next();\r
+            allModules.add(new ModuleInfo(id, pcdBuildDefinitions.get(id)));    \r
         }\r
         \r
         return allModules;\r
@@ -1824,34 +1911,6 @@ public class CollectPCDAction {
         // -------------------------------------------------------------------\r
         // \r
         for (index = 0; index < modules.size(); index ++) {\r
-            isDuplicate =  false;\r
-            for (index2 = 0; index2 < index; index2 ++) {\r
-                //\r
-                // BUGBUG: For transition schema, we can *not* get module's version from \r
-                // <ModuleSAs>, It is work around code.\r
-                // \r
-                primaryKey1 = UsageInstance.getPrimaryKey(modules.get(index).getModuleId().getModule().getName(), \r
-                                                          null,\r
-                                                          null,\r
-                                                          null, \r
-                                                          modules.get(index).getModuleId().getArch(),\r
-                                                          null);\r
-                primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).getModuleId().getModule().getName(), \r
-                                                          null, \r
-                                                          null, \r
-                                                          null, \r
-                                                          modules.get(index2).getModuleId().getArch(), \r
-                                                          null);\r
-                if (primaryKey1.equalsIgnoreCase(primaryKey2)) {\r
-                    isDuplicate = true;\r
-                    break;\r
-                }\r
-            }\r
-\r
-            if (isDuplicate) {\r
-                continue;\r
-            }\r
-\r
            //\r
            // It is legal for a module does not contains ANY pcd build definitions.\r
            // \r
@@ -1881,8 +1940,7 @@ public class CollectPCDAction {
                     throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName());\r
                 } \r
 \r
-                primaryKey   = Token.getPrimaryKeyString(pcdBuildData.getCName(),\r
-                                                         translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+                primaryKey   = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
                 pcdType      = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());\r
                 datumType    = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());\r
                 tokenNumber  = Long.decode(pcdBuildData.getToken().toString());\r
@@ -2021,8 +2079,7 @@ public class CollectPCDAction {
                         throw new EntityException("Fail to get token space guid for token " + token.cName);\r
                     }\r
 \r
-                    token = new Token(pcdBuildData.getCName(), \r
-                                      translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+                    token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
     \r
                     token.datumType     = datumType;\r
                     token.tokenNumber   = tokenNumber;\r
@@ -2056,14 +2113,9 @@ public class CollectPCDAction {
                 // ------------------------------------------------\r
                 // \r
                 usageInstance = new UsageInstance(token, \r
-                                                  moduleName, \r
-                                                  null,\r
-                                                  null,\r
-                                                  null,\r
-                                                  CommonDefinition.getModuleType(modules.get(index).getModuleType()), \r
+                                                  modules.get(index).getModuleId().getModule(), \r
                                                   pcdType,\r
                                                   modules.get(index).getModuleId().getArch(), \r
-                                                  null,\r
                                                   datum,\r
                                                   maxDatumSize);\r
                 token.addUsageInstance(usageInstance);\r
@@ -2103,7 +2155,8 @@ public class CollectPCDAction {
         String  variableGuidString[];\r
 \r
         //\r
-        // If FPD document is not be opened, open and initialize it.\r
+        // Open fpd document to get <DynamicPcdBuildDefinition> Section.\r
+        // BUGBUG: the function should be move GlobalData in furture.\r
         // \r
         if (fpdDocInstance == null) {\r
             try {\r
@@ -2134,7 +2187,7 @@ public class CollectPCDAction {
             } \r
 \r
             primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),\r
-                                                   translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+                                                   tokenSpaceStrRet[1]);\r
 \r
             if (dbManager.isTokenInDatabase(primaryKey)) {\r
                 continue;\r
@@ -2149,7 +2202,7 @@ public class CollectPCDAction {
             //\r
             // Create new token for unreference dynamic PCD token\r
             // \r
-            token           = new Token(pcdBuildData.getCName(), translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+            token           = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
             token.datumSize = pcdBuildData.getMaxDatumSize();\r
             \r
 \r
@@ -2662,6 +2715,7 @@ public class CollectPCDAction {
 \r
         //\r
         // If FPD document is not be opened, open and initialize it.\r
+        // BUGBUG: The code should be moved into GlobalData in future.\r
         // \r
         if (fpdDocInstance == null) {\r
             try {\r
@@ -2697,7 +2751,7 @@ public class CollectPCDAction {
             }\r
 \r
             dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),\r
-                                                          translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+                                                          tokenSpaceStrRet[1]);\r
             if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {\r
                 return dynamicPcdBuildDataArray.get(index);\r
             }\r
index ad4ebe78af01487d9a0f0ebad4f8ad33caa807d7..2707c5d1a85dae4336263eb5e00e126de27640e1 100644 (file)
@@ -28,6 +28,7 @@ import java.util.regex.Pattern;
 import org.apache.xmlbeans.XmlObject;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.global.SurfaceAreaQuery;\r
+import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
 import org.tianocore.build.pcd.entity.Token;\r
 import org.tianocore.build.pcd.entity.UsageInstance;\r
@@ -43,30 +44,14 @@ public class PCDAutoGenAction extends BuildAction {
     ///\r
     private MemoryDatabaseManager dbManager;\r
     ///\r
-    /// The name of module which is analysised currently.\r
-    ///\r
-    private String                moduleName;\r
-    ///\r
-    /// The Guid of module which is analyzed currently.\r
-    /// \r
-    private UUID                  moduleGuid;\r
-    ///\r
-    /// The name of package whose module is analysized currently.\r
+    /// The identification for a module.\r
     /// \r
-    private String                packageName;\r
-    ///\r
-    /// The Guid of package whose module is analyszed curretnly.\r
-    /// \r
-    private UUID                  packageGuid;\r
+    private ModuleIdentification  moduleId;\r
     ///\r
     /// The arch of current module\r
     /// \r
     private String                arch;\r
     ///\r
-    /// The version of current module\r
-    /// \r
-    private String                version;\r
-    ///\r
     /// Whether current autogen is for building library used by current module.\r
     /// \r
     private boolean               isBuildUsedLibrary;\r
@@ -81,41 +66,14 @@ public class PCDAutoGenAction extends BuildAction {
     ///\r
     /// The name array of <PcdCoded> in a module.\r
     /// \r
-    private String[]              pcdNameArray;\r
+    private String[]              pcdNameArrayInMsa;\r
     /**\r
-      Set parameter ModuleName\r
+      Set parameter moduleId\r
   \r
       @param moduleName   the module name parameter.\r
     **/\r
-    public void setModuleName(String moduleName) {\r
-        this.moduleName = moduleName;\r
-    }\r
-\r
-    /**\r
-       set the moduleGuid parameter.\r
-       \r
-       @param moduleGuid\r
-    **/\r
-    public void setModuleGuid(UUID moduleGuid) {\r
-        this.moduleGuid = moduleGuid;\r
-    }\r
-\r
-    /**\r
-       set packageName parameter.\r
-       \r
-       @param packageName\r
-    **/\r
-    public void setPackageName(String packageName) {\r
-        this.packageName = packageName;\r
-    }\r
-\r
-    /**\r
-        set packageGuid parameter.\r
-       \r
-       @param packageGuid\r
-    **/\r
-    public void setPackageGuid(UUID packageGuid) {\r
-        this.packageGuid = packageGuid;\r
+    public void setModuleId(ModuleIdentification moduleId) {\r
+        this.moduleId = moduleId;\r
     }\r
 \r
     /**\r
@@ -127,30 +85,22 @@ public class PCDAutoGenAction extends BuildAction {
         this.arch = arch;\r
     }\r
 \r
-    /**\r
-       set version parameter\r
-       \r
-       @param version\r
-     */\r
-    public void setVersion(String version) {\r
-        this.version = version;\r
-    }\r
-\r
     /**\r
        set isBuildUsedLibrary parameter.\r
        \r
        @param isBuildUsedLibrary\r
-     */\r
+    **/\r
     public void setIsBuildUsedLibrary(boolean isBuildUsedLibrary) {\r
         this.isBuildUsedLibrary = isBuildUsedLibrary;\r
     }\r
+\r
     /**\r
-       set pcdNameArray parameter.\r
+       set pcdNameArrayInMsa parameter.\r
        \r
-       @param pcdNameArray\r
+       @param pcdNameArrayInMsa\r
      */\r
-    public void setPcdNameArray(String[] pcdNameArray) {\r
-        this.pcdNameArray = pcdNameArray;\r
+    public void setPcdNameArrayInMsa(String[] pcdNameArrayInMsa) {\r
+        this.pcdNameArrayInMsa = pcdNameArrayInMsa;\r
     }\r
 \r
     /**\r
@@ -171,160 +121,31 @@ public class PCDAutoGenAction extends BuildAction {
         return cAutoGenString;\r
     }\r
 \r
-//    /**\r
-//      Construct function\r
-//  \r
-//      This function mainly initialize some member variable.\r
-//     \r
-//      @param moduleName            Parameter of this action class.\r
-//      @param isEmulatedPCDDriver   Parameter of this action class.\r
-//    **/\r
-//    public PCDAutoGenAction(String   moduleName, \r
-//                            UUID     moduleGuid, \r
-//                            String   packageName,\r
-//                            UUID     packageGuid,\r
-//                            String   arch,\r
-//                            String   version,\r
-//                            boolean  isBuildUsedLibrary,\r
-//                            String[] pcdNameArray) {\r
-//        dbManager       = null;\r
-//        hAutoGenString  = "";\r
-//        cAutoGenString  = "";\r
-//\r
-//        setModuleName(moduleName);\r
-//        setModuleGuid(moduleGuid);\r
-//        setPackageName(packageName);\r
-//        setPackageGuid(packageGuid);\r
-//        setPcdNameArray(pcdNameArray);\r
-//        setArch(arch);\r
-//        setVersion(version);\r
-//        setIsBuildUsedLibrary(isBuildUsedLibrary);\r
-//    }\r
-\r
-    \r
+   \r
     /**\r
-    Construct function\r
+        Construct function\r
 \r
-    This function mainly initialize some member variable.\r
+        This function mainly initialize some member variable.\r
    \r
-    @param moduleName            Parameter of this action class.\r
-    @param isEmulatedPCDDriver   Parameter of this action class.\r
-  **/\r
-  public PCDAutoGenAction(String   moduleName, \r
-                          String   moduleGuidString, \r
-                          String   packageName,\r
-                          String   packageGuidString,\r
-                          String   arch,\r
-                          String   version,\r
-                          boolean  isBuildUsedLibrary,\r
-                          String[] pcdNameArray) \r
-       throws BuildActionException {\r
-      dbManager       = null;\r
-      hAutoGenString  = "";\r
-      cAutoGenString  = "";\r
-      try {\r
-          setModuleName(moduleName);\r
-          setModuleGuid(translateSchemaStringToUUID(moduleGuidString));\r
-          setPackageName(packageName);\r
-          setPackageGuid(translateSchemaStringToUUID(packageGuidString));\r
-          setPcdNameArray(pcdNameArray);\r
-          setArch(arch);\r
-          setVersion(version);\r
-          setIsBuildUsedLibrary(isBuildUsedLibrary);\r
-      } catch (EntityException e){\r
-         throw new BuildActionException(e.getMessage());\r
-      }\r
-  }\r
-\r
-  /**\r
-  Translate the schema string to UUID instance.\r
-  \r
-  In schema, the string of UUID is defined as following two types string:\r
-   1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(\r
-   )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?\r
-  \r
-   2) GuidNamingConvention: pattern =\r
-   [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\r
-  \r
-  This function will convert string and create uuid instance.\r
-  \r
-  @param uuidString    UUID string in XML file\r
-  \r
-  @return UUID         UUID instance\r
-**/\r
-private UUID translateSchemaStringToUUID(String uuidString) \r
-   throws EntityException {\r
-   String      temp;\r
-   String[]    splitStringArray;\r
-   int         index;\r
-   int         chIndex;\r
-   int         chLen;\r
-\r
-   if (uuidString == null) {\r
-       return null;\r
-   }\r
-\r
-   if (uuidString.length() == 0) {\r
-       return null;\r
-   }\r
-\r
-   if (uuidString.equals("0") ||\r
-       uuidString.equalsIgnoreCase("0x0")) {\r
-       return new UUID(0, 0);\r
-   }\r
-\r
-   uuidString = uuidString.replaceAll("\\{", "");\r
-   uuidString = uuidString.replaceAll("\\}", "");\r
-\r
-   //\r
-   // If the UUID schema string is GuidArrayType type then need translate \r
-   // to GuidNamingConvention type at first.\r
-   // \r
-   if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {\r
-       splitStringArray = uuidString.split("," );\r
-       if (splitStringArray.length != 11) {\r
-           throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString);\r
-       }\r
-\r
-       //\r
-       // Remove blank space from these string and remove header string "0x"\r
-       // \r
-       for (index = 0; index < 11; index ++) {\r
-           splitStringArray[index] = splitStringArray[index].trim();\r
-           splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length());\r
-       }\r
-\r
-       //\r
-       // Add heading '0' to normalize the string length\r
-       // \r
-       for (index = 3; index < 11; index ++) {\r
-           chLen = splitStringArray[index].length();\r
-           for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) {\r
-               splitStringArray[index] = "0" + splitStringArray[index];\r
-           }\r
-       }\r
-\r
-       //\r
-       // construct the final GuidNamingConvention string\r
-       // \r
-       temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",\r
-                            splitStringArray[0],\r
-                            splitStringArray[1],\r
-                            splitStringArray[2],\r
-                            splitStringArray[3],\r
-                            splitStringArray[4],\r
-                            splitStringArray[5],\r
-                            splitStringArray[6],\r
-                            splitStringArray[7],\r
-                            splitStringArray[8],\r
-                            splitStringArray[9],\r
-                            splitStringArray[10]);\r
-       uuidString = temp;\r
-   }\r
-\r
-   return UUID.fromString(uuidString);\r
-       }\r
-  \r
+        @param moduleId             the identification for module\r
+        @param arch                 the architecture for module\r
+        @param isBuildUsedLibary    Is the current module library.\r
+        @param pcdNameArrayInMsa    the pcd name array got from MSA file.\r
+    **/\r
+    public PCDAutoGenAction(ModuleIdentification moduleId, \r
+                            String               arch,\r
+                            boolean              isBuildUsedLibrary,\r
+                            String[]             pcdNameArrayInMsa) {\r
+        dbManager       = null;\r
+        hAutoGenString  = "";\r
+        cAutoGenString  = "";\r
+\r
+        setModuleId(moduleId);\r
+        setArch(arch);\r
+        setIsBuildUsedLibrary(isBuildUsedLibrary);\r
+        setPcdNameArrayInMsa(pcdNameArrayInMsa);\r
+    }\r
+\r
     /**\r
       check the parameter for action class.\r
       \r
@@ -363,8 +184,6 @@ private UUID translateSchemaStringToUUID(String uuidString)
         ActionMessage.debug(this,\r
                             "PCD memory database contains " + dbManager.getDBSize() + " PCD tokens");\r
 \r
-\r
-\r
         generateAutogenForModule();\r
     }\r
 \r
@@ -381,32 +200,23 @@ private UUID translateSchemaStringToUUID(String uuidString)
         String[]              guidStringArray = null;\r
         String                guidStringCName = null;\r
         String                guidString      = null;\r
+        String                moduleName      = moduleId.getName();\r
         UsageInstance         usageInstance   = null;\r
         boolean               found           = false;\r
 \r
         usageInstanceArray = null;\r
         if (!isBuildUsedLibrary) {\r
-            usageInstanceArray  = dbManager.getUsageInstanceArrayByModuleName(moduleName,\r
-                                                                              moduleGuid,\r
-                                                                              packageName,\r
-                                                                              packageGuid,\r
-                                                                              arch,\r
-                                                                              version);\r
+            usageInstanceArray  = dbManager.getUsageInstanceArrayByModuleName(moduleId, arch);\r
             dbManager.UsageInstanceContext = usageInstanceArray;\r
             dbManager.CurrentModuleName    = moduleName; \r
-        } else if ((pcdNameArray != null) && (pcdNameArray.length > 0)) {\r
+        } else if ((pcdNameArrayInMsa != null) && (pcdNameArrayInMsa.length > 0)) {\r
             usageContext = dbManager.UsageInstanceContext;\r
             //\r
             // For building library package, although all module are library, but PCD entries of \r
             // these library should be used to autogen.\r
             // \r
             if (usageContext == null) {\r
-                usageInstanceArray  = dbManager.getUsageInstanceArrayByModuleName(moduleName,\r
-                                                                                  moduleGuid,\r
-                                                                                  packageName,\r
-                                                                                  packageGuid,\r
-                                                                                  arch,\r
-                                                                                  version);\r
+                usageInstanceArray  = dbManager.getUsageInstanceArrayByModuleName(moduleId, arch);\r
             } else {\r
                 usageInstanceArray = new ArrayList<UsageInstance>();\r
 \r
@@ -414,10 +224,10 @@ private UUID translateSchemaStringToUUID(String uuidString)
                 // Try to find all PCD defined in library's PCD in all <PcdEntry> in module's \r
                 // <ModuleSA> in FPD file.\r
                 // \r
-                for (index = 0; index < pcdNameArray.length; index++) {\r
+                for (index = 0; index < pcdNameArrayInMsa.length; index++) {\r
                     found = false;\r
                     for (index2 = 0; index2 < usageContext.size(); index2 ++) {\r
-                        if (pcdNameArray[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {\r
+                        if (pcdNameArrayInMsa[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {\r
                             usageInstanceArray.add(usageContext.get(index2));\r
                             found = true;\r
                             break;\r
@@ -434,7 +244,7 @@ private UUID translateSchemaStringToUUID(String uuidString)
                                                                       "it in the %s's <ModuleSA> in FPD file!",\r
                                                                       dbManager.CurrentModuleName,\r
                                                                       moduleName,\r
-                                                                      pcdNameArray[index],\r
+                                                                      pcdNameArrayInMsa[index],\r
                                                                       dbManager.CurrentModuleName\r
                                                                       ));\r
                     }\r
@@ -450,63 +260,55 @@ private UUID translateSchemaStringToUUID(String uuidString)
         // Generate all PCD entry for a module.\r
         // \r
         for(index = 0; index < usageInstanceArray.size(); index ++) {\r
-            ActionMessage.debug(this,\r
-                                "Module " + moduleName + "'s PCD [" + Integer.toHexString(index) + \r
-                                "]: " + usageInstanceArray.get(index).parentToken.cName);\r
-            try {\r
-                usageInstance = usageInstanceArray.get(index);\r
+            usageInstance = usageInstanceArray.get(index);\r
+            //\r
+            // Before generate any PCD information into autogen.h/autogen.c for a module,\r
+            // generate TokenSpaceGuid array variable firstly. For every dynamicEx type\r
+            // PCD in this module the token, they are all reference to TokenSpaceGuid \r
+            // array.\r
+            // \r
+            if (usageInstanceArray.get(index).modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+                guidStringArray = usageInstance.parentToken.tokenSpaceName.split("-");\r
+                guidStringCName = "_gPcd_TokenSpaceGuid_" + \r
+                                  usageInstance.parentToken.tokenSpaceName.replaceAll("-", "_");\r
+                guidString      = String.format("{ 0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}",\r
+                                                guidStringArray[0],\r
+                                                guidStringArray[1],\r
+                                                guidStringArray[2],\r
+                                                (guidStringArray[3].substring(0, 2)),\r
+                                                (guidStringArray[3].substring(2, 4)),\r
+                                                (guidStringArray[4].substring(0, 2)),\r
+                                                (guidStringArray[4].substring(2, 4)),\r
+                                                (guidStringArray[4].substring(4, 6)),\r
+                                                (guidStringArray[4].substring(6, 8)),\r
+                                                (guidStringArray[4].substring(8, 10)),\r
+                                                (guidStringArray[4].substring(10, 12)));\r
+                \r
+                Pattern pattern = Pattern.compile("(" + guidStringCName + ")+?");\r
+                Matcher matcher = pattern.matcher(cAutoGenString + " ");\r
                 //\r
-                // Before generate any PCD information into autogen.h/autogen.c for a module,\r
-                // generate TokenSpaceGuid array variable firstly. For every dynamicEx type\r
-                // PCD in this module the token, they are all reference to TokenSpaceGuid \r
-                // array.\r
+                // Find whether this guid array variable has been generated into autogen.c\r
+                // For different DyanmicEx pcd token who use same token space guid, the token space\r
+                // guid array should be only generated once.\r
                 // \r
-                if (usageInstanceArray.get(index).modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
-                    guidStringArray = usageInstance.parentToken.tokenSpaceName.toString().split("-");\r
-                    guidStringCName = "_gPcd_TokenSpaceGuid_" + \r
-                                      usageInstance.parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
-                    guidString      = String.format("{ 0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}",\r
-                                                    guidStringArray[0],\r
-                                                    guidStringArray[1],\r
-                                                    guidStringArray[2],\r
-                                                    (guidStringArray[3].substring(0, 2)),\r
-                                                    (guidStringArray[3].substring(2, 4)),\r
-                                                    (guidStringArray[4].substring(0, 2)),\r
-                                                    (guidStringArray[4].substring(2, 4)),\r
-                                                    (guidStringArray[4].substring(4, 6)),\r
-                                                    (guidStringArray[4].substring(6, 8)),\r
-                                                    (guidStringArray[4].substring(8, 10)),\r
-                                                    (guidStringArray[4].substring(10, 12)));\r
-                    \r
-                    Pattern pattern = Pattern.compile("(" + guidStringCName + ")+?");\r
-                    Matcher matcher = pattern.matcher(cAutoGenString + " ");\r
-                    //\r
-                    // Find whether this guid array variable has been generated into autogen.c\r
-                    // For different DyanmicEx pcd token who use same token space guid, the token space\r
-                    // guid array should be only generated once.\r
-                    // \r
-                    if (!matcher.find()) {\r
-                        hAutoGenString += String.format("extern EFI_GUID %s;\r\n",\r
-                                                        guidStringCName);\r
-                        if (!isBuildUsedLibrary) {\r
-                            cAutoGenString += String.format("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID %s = %s;\r\n",\r
-                                                            guidStringCName,\r
-                                                            guidString);\r
-                        } \r
-                    }\r
+                if (!matcher.find()) {\r
+                    hAutoGenString += String.format("extern EFI_GUID %s;\r\n",\r
+                                                    guidStringCName);\r
+                    if (!isBuildUsedLibrary) {\r
+                        cAutoGenString += String.format("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID %s = %s;\r\n",\r
+                                                        guidStringCName,\r
+                                                        guidString);\r
+                    } \r
                 }\r
-\r
-                usageInstance.generateAutoGen(isBuildUsedLibrary);\r
-                //\r
-                // For every PCD entry for this module(usage instance), autogen string would\r
-                // be appand.\r
-                // \r
-                hAutoGenString += usageInstance.getHAutogenStr() + "\r\n";\r
-                cAutoGenString += usageInstance.getCAutogenStr();\r
-\r
-            } catch(EntityException exp) {\r
-                throw new BuildActionException("[PCD Autogen Error]: " + exp.getMessage());\r
             }\r
+\r
+            usageInstance.generateAutoGen(isBuildUsedLibrary);\r
+            //\r
+            // For every PCD entry for this module(usage instance), autogen string would\r
+            // be appand.\r
+            // \r
+            hAutoGenString += usageInstance.getHAutogenStr() + "\r\n";\r
+            cAutoGenString += usageInstance.getCAutogenStr();\r
         }\r
 \r
         //\r
@@ -520,13 +322,6 @@ private UUID translateSchemaStringToUUID(String uuidString)
             hAutoGenString += dbManager.PcdDxeHString;\r
             cAutoGenString += dbManager.PcdDxeCString;\r
         }\r
-\r
-        ActionMessage.debug(this,\r
-                            "Module " + moduleName + "'s PCD header file:\r\n" + hAutoGenString + "\r\n"\r
-                           );\r
-        ActionMessage.debug(this,\r
-                             "Module " + moduleName + "'s PCD C file:\r\n" + cAutoGenString + "\r\n"\r
-                            );\r
     }\r
 \r
     /**\r
@@ -555,22 +350,5 @@ private UUID translateSchemaStringToUUID(String uuidString)
         } catch(Exception e) {\r
             e.printStackTrace();\r
         }\r
-\r
-        //\r
-        // Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c\r
-        //\r
-//        PCDAutoGenAction autogenAction = new PCDAutoGenAction("MonoStatusCode",\r
-//                                                              null,\r
-//                                                              null,\r
-//                                                              null,\r
-//                                                              "IA32",\r
-//                                                              null,\r
-//                                                              false,\r
-//                                                              nameArray);\r
-//        autogenAction.execute();\r
-//\r
-//        System.out.println(autogenAction.OutputH());\r
-//        System.out.println("WQWQWQWQWQ");\r
-//        System.out.println(autogenAction.OutputC());\r
     }\r
 }\r
index 65c15a5eb53b4d902e96f6b577b220bf63dcacce..533bd51920dedd6c60f3db78d27c814ce8f23f50 100644 (file)
@@ -133,26 +133,6 @@ public class DynamicTokenValue {
         return str;\r
     }\r
 \r
-    /**\r
-       Get UINT16 array which use string to express a number.\r
-       \r
-       @return String\r
-     */\r
-    public String getStringArrayOfVariableName() {\r
-        String  strArray;\r
-        int     index;\r
-\r
-        strArray =  "{";\r
-        for (index = 0; index < variableName.size(); index ++) {\r
-            strArray += variableName.get(index).toString();\r
-            if (index != (variableName.size() - 1)) {\r
-                strArray += ",";\r
-            }\r
-        }\r
-        strArray += "}";\r
-        return strArray;\r
-    }\r
-\r
     /**\r
        Set Vpd case data.\r
        \r
index 2e29106323e22d13798b59462021160ccb14029d..636be3adaf201289e7dbf59f45519fa1ec7c0a3d 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;\r
 import java.util.UUID;\r
 \r
+import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.pcd.exception.EntityException;\r
 \r
 /** Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
@@ -38,14 +39,20 @@ public class MemoryDatabaseManager {
     /// context of building libary.\r
     /// \r
     public static List<UsageInstance> UsageInstanceContext = null;\r
+\r
     ///\r
-    /// \r
+    /// Current module name, if now is buiding library, this value indicate this library\r
+    /// is for building what module.\r
     /// \r
     public static String CurrentModuleName                 = null;\r
-    public static String PcdPeimHString       = "";\r
-    public static String PcdPeimCString       = "";\r
-    public static String PcdDxeHString        = "";\r
-    public static String PcdDxeCString        = "";\r
+\r
+    ///\r
+    /// String for PCD PEIM and DXE autogen file\r
+    /// \r
+    public static String PcdPeimHString                    = "";\r
+    public static String PcdPeimCString                    = "";\r
+    public static String PcdDxeHString                     = "";\r
+    public static String PcdDxeCString                     = "";\r
 \r
     /**\r
       Constructure function\r
@@ -151,7 +158,7 @@ public class MemoryDatabaseManager {
           The output array is sorted based on descending order of the size of alignment for each feilds.\r
 \r
       @return the token record array contained all PCD token referenced in PEI phase.\r
-     * @throws EntityException \r
+      @throws EntityException\r
     **/\r
     public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) \r
         throws EntityException {\r
@@ -204,7 +211,7 @@ public class MemoryDatabaseManager {
                         // We only support Dynamice(EX) type for PEI and DXE phase.\r
                         // If it is not referenced in either PEI or DXE, throw exception now.\r
                         //\r
-                        throw new EntityException("Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");\r
+                        throw new EntityException("[PCD tool Internal Error] Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");\r
                     }\r
                 }\r
             }\r
@@ -217,23 +224,15 @@ public class MemoryDatabaseManager {
       Get all PCD record for a module according to module's name, module's GUID,\r
       package name, package GUID, arch, version information.\r
      \r
-      @param moduleName  the name of module.\r
+      @param moduleId  the id of module.\r
+      @param arch      the architecture\r
       \r
       @return  all usage instance for this module in memory database.\r
     **/\r
-    public List<UsageInstance> getUsageInstanceArrayByModuleName(String moduleName,\r
-                                                                 UUID   moduleGuid,\r
-                                                                 String packageName,\r
-                                                                 UUID   packageGuid,\r
-                                                                 String arch,\r
-                                                                 String version) {\r
-\r
-        String primaryKey = UsageInstance.getPrimaryKey(moduleName, \r
-                                                        moduleGuid,\r
-                                                        packageName,\r
-                                                        packageGuid,\r
-                                                        arch,\r
-                                                        version);\r
+    public List<UsageInstance> getUsageInstanceArrayByModuleName(ModuleIdentification  moduleId,\r
+                                                                 String                arch) {\r
+\r
+        String primaryKey = UsageInstance.getPrimaryKey(moduleId, arch);\r
 \r
         return getUsageInstanceArrayByKeyString(primaryKey);\r
     }\r
index 8a492256c4aa8981a2a76e94e03b9f80bde1d9d1..20b4f4e01adb4eb1eb85dfa44522cd90f4c4f53d 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Map;\r
 import java.util.UUID;\r
 \r
+import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.pcd.exception.EntityException;\r
 \r
 /** This class is to descript a PCD token object. The information of a token mainly \r
@@ -60,19 +61,19 @@ public class Token {
     /// assignedtokenSpaceName as follows.\r
     /// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.\r
     ///\r
-    public UUID             tokenSpaceName;\r
+    public String           tokenSpaceName;\r
 \r
     ///\r
     /// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in\r
     /// platform token space. For Dynamic, dynamicEx type, this number will be re-adjust by\r
     /// PCD run-time database autogen tools.\r
     ///\r
-    public long              tokenNumber;\r
+    public long             tokenNumber;\r
 \r
     ///\r
     /// This token number is retrieved from FPD file for DynamicEx type. \r
     /// \r
-    public long              dynamicExTokenNumber;\r
+    public long             dynamicExTokenNumber;\r
 \r
     ///\r
     /// All supported PCD type, this value can be retrieved from SPD\r
@@ -110,11 +111,17 @@ public class Token {
     ///\r
     public Map<String, UsageInstance>  consumers;\r
 \r
-    public Token(String cName, UUID tokenSpaceName) {\r
+    /**\r
+       Constructure function for Token class\r
+       \r
+       @param cName             The name of token\r
+       @param tokenSpaceName    The name of token space, it is a guid string\r
+    **/\r
+    public Token(String cName, String tokenSpaceName) {\r
         UUID    nullUUID = new UUID(0, 0);\r
 \r
         this.cName                  = cName;\r
-        this.tokenSpaceName         = (tokenSpaceName == null) ? nullUUID : tokenSpaceName;\r
+        this.tokenSpaceName         = tokenSpaceName;\r
         this.tokenNumber            = 0;\r
         this.datumType              = DATUM_TYPE.UNKNOWN;\r
         this.datumSize              = -1;\r
@@ -133,24 +140,23 @@ public class Token {
       @param pcdType    new PCD type found in FPD file for this token.\r
     **/\r
     public void updateSupportPcdType(PCD_TYPE pcdType) {\r
-        int     index = 0;\r
-        boolean found = false;\r
-        for (index = 0; index < this.supportedPcdType.size(); index ++) {\r
-            if (this.supportedPcdType.get(index) == pcdType) {\r
-                found = true;\r
-                break;\r
+        for (int index = 0; index < this.supportedPcdType.size(); index ++) {\r
+            if (supportedPcdType.get(index) == pcdType) {\r
+                return;\r
             }\r
         }\r
-        if (!found) {\r
-            this.supportedPcdType.add(pcdType);\r
-        }\r
+\r
+        //\r
+        // If not found, add the pcd type to member variable supportedPcdType\r
+        // \r
+        supportedPcdType.add(pcdType);\r
     }\r
 \r
     /**\r
        Judge whether pcdType is belong to dynamic type. Dynamic type includes\r
        DYNAMIC and DYNAMIC_EX.\r
        \r
-       @param pcdType\r
+       @param pcdType       the judged pcd type\r
        \r
        @return boolean\r
      */\r
@@ -164,7 +170,6 @@ public class Token {
     }\r
 \r
     public boolean isDynamicEx() {\r
-        \r
         for (int i = 0; i < supportedPcdType.size(); i++) {\r
             if (supportedPcdType.get(i) == PCD_TYPE.DYNAMIC_EX) {\r
                 return true;\r
@@ -178,16 +183,13 @@ public class Token {
       Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database\r
       \r
       @param   cName                     Token name.\r
-      @param   tokenSpaceName            The token space guid defined in MSA or SPD\r
-      @param   platformtokenSpaceName    The token space guid for current platform token space,\r
+      @param   tokenSpaceName            The token space guid string defined in MSA or SPD\r
       \r
-      @return  primary key for this token in token database.\r
+      @retval  primary key for this token in token database.\r
     **/\r
-    public static String getPrimaryKeyString(String cName, UUID tokenSpaceName) {\r
-        UUID  nullUUID = new UUID(0, 0);\r
-\r
+    public static String getPrimaryKeyString(String cName, String tokenSpaceName) {\r
         if (tokenSpaceName == null) {\r
-            return cName + "_" + nullUUID.toString().replace('-', '_');\r
+            return cName + "_nullTokenSpaceGuid";\r
         } else {\r
             return cName + "_" + tokenSpaceName.toString().replace('-', '_');\r
         }\r
@@ -196,7 +198,7 @@ public class Token {
     /**\r
        If skudata list contains more than one data, then Sku mechanism is enable.\r
        \r
-       @return boolean\r
+       @retval boolean  if the number of sku data exceed to 1\r
      */\r
     public boolean isSkuEnable() {\r
         if (this.skuData.size() > 1) {\r
@@ -204,7 +206,12 @@ public class Token {
         }\r
         return false;\r
     }\r
-    \r
+\r
+    /**\r
+       If Hii type for value of token\r
+       \r
+       @return boolean\r
+    **/\r
     public boolean isHiiEnable() {\r
         if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {\r
             return true;\r
@@ -212,6 +219,11 @@ public class Token {
         return false;\r
     }\r
 \r
+    /**\r
+       If Vpd type for value of token\r
+       \r
+       @return boolean\r
+    **/\r
     public boolean isVpdEnable() {\r
         if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {\r
             return true;\r
@@ -268,52 +280,38 @@ public class Token {
       @retval TRUE  - Success to add usage instance.\r
       @retval FALSE - Fail to add usage instance\r
     **/\r
-    public boolean addUsageInstance(UsageInstance usageInstance) \r
-        throws EntityException {\r
+    public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {\r
         String exceptionStr;\r
 \r
-        if (isUsageInstanceExist(usageInstance.moduleName,\r
-                                 usageInstance.moduleGUID,\r
-                                 usageInstance.packageName,\r
-                                 usageInstance.packageGUID,\r
-                                 usageInstance.arch,\r
-                                 usageInstance.version)) {\r
-            exceptionStr = String.format("PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
-                                         "in modules %s in <ModuleSA> to make sure no duplicated definitions!",\r
+        if (isUsageInstanceExist(usageInstance.moduleId, usageInstance.arch)) {\r
+            exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
+                                         "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",\r
                                          usageInstance.parentToken.cName,\r
-                                         usageInstance.moduleName,\r
-                                         usageInstance.moduleName);\r
+                                         usageInstance.moduleId.getName(),\r
+                                         usageInstance.moduleId.getName());\r
             throw new EntityException(exceptionStr);\r
         }\r
 \r
+        //\r
+        // Put usage instance into usage instance database of this PCD token.\r
+        // \r
         consumers.put(usageInstance.getPrimaryKey(), usageInstance);\r
+\r
         return true;\r
     }\r
 \r
     /**\r
        Judge whether exist an usage instance for this token\r
        \r
-       @param moduleName    the name of module\r
-       @param moduleGuid    the GUID name of modules\r
-       @param packageName   the name of package contains this module\r
-       @param packageGuid   the GUID name of package contains this module\r
+       @param moduleId      The module identification for usage instance\r
        @param arch          the architecture string\r
-       @param version       the version string\r
        \r
        @return boolean      whether exist an usage instance for this token.\r
      */\r
-    public boolean isUsageInstanceExist(String moduleName,\r
-                                        UUID   moduleGuid,\r
-                                        String packageName,\r
-                                        UUID   packageGuid,\r
-                                        String arch,\r
-                                        String version) {\r
-        String keyStr = UsageInstance.getPrimaryKey(moduleName, \r
-                                                    moduleGuid, \r
-                                                    packageName, \r
-                                                    packageGuid, \r
-                                                    arch, \r
-                                                    version);\r
+    public boolean isUsageInstanceExist(ModuleIdentification moduleId,\r
+                                        String               arch) {\r
+        String keyStr = UsageInstance.getPrimaryKey(moduleId, arch);\r
+\r
         return (consumers.get(keyStr) != null);\r
     }\r
 \r
@@ -542,27 +540,14 @@ public class Token {
     }\r
 \r
     /**\r
-      UUID defined in Schems is object, this function is to tranlate this object \r
-      to UUID data.\r
-      \r
-      @param uuidObj The object comes from schema.\r
-      \r
-      @return The traslated UUID instance.\r
+       Get the sku data who id is 0.\r
+       \r
+       @retval DynamicTokenValue    the value of this dyanmic token.\r
     **/\r
-    public static UUID getGUIDFromSchemaObject(Object uuidObj) {\r
-        UUID uuid;\r
-        if (uuidObj.toString().equalsIgnoreCase("0")) {\r
-            uuid = new UUID(0,0);\r
-        } else {\r
-            uuid = UUID.fromString(uuidObj.toString());\r
-        }\r
-\r
-        return uuid;\r
-    }\r
-\r
     public DynamicTokenValue getDefaultSku() {\r
         DynamicTokenValue dynamicData;\r
         int               index;\r
+\r
         for (index = 0; index < this.skuData.size(); index ++) {\r
             if (skuData.get(index).id == 0) {\r
                 return skuData.get(index).value;\r
@@ -571,11 +556,22 @@ public class Token {
 \r
         return null;\r
     }\r
-    \r
+\r
+    /**\r
+       Get the number of Sku data for this token\r
+       \r
+       @retval int the number of sku data\r
+    **/\r
     public int getSkuIdCount () {\r
         return this.skuData.size();\r
     }\r
 \r
+    /**\r
+       Get the size of PCD value, this PCD is POINTER type.\r
+       \r
+       @param str   the string of the value\r
+       @param al    \r
+    **/\r
     private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {\r
         if (isValidNullValue(str)) {\r
             al.add(new Integer(0));\r
@@ -616,10 +612,11 @@ public class Token {
             }\r
         }\r
     }\r
-    //\r
-    // This method can be used to get the MAX and current size\r
-    // for pointer type dynamic(ex) PCD entry\r
-    //\r
+\r
+    /**\r
+       This method can be used to get the MAX and current size\r
+       for pointer type dynamic(ex) PCD entry\r
+    **/ \r
     public ArrayList<Integer> getPointerTypeSize () {\r
         ArrayList<Integer> al = new ArrayList<Integer>();\r
         \r
@@ -695,6 +692,13 @@ public class Token {
         return false;\r
     }\r
 \r
+    /**\r
+       Judge the value is NULL value. NULL value means the value is uninitialized value\r
+       \r
+       @param judgedValue\r
+       \r
+       @return boolean\r
+     */\r
     public boolean isValidNullValue(String judgedValue) {\r
         String      subStr;\r
         BigInteger  bigIntValue;\r
@@ -756,7 +760,12 @@ public class Token {
         }\r
         return false;\r
     }\r
-    \r
+\r
+    /**\r
+       Is the string value in Unicode\r
+       \r
+       @return boolean\r
+    **/\r
     public boolean isHiiDefaultValueUnicodeStringType() {\r
         DynamicTokenValue dynamicData = getDefaultSku();\r
         \r
@@ -766,7 +775,12 @@ public class Token {
         return dynamicData.hiiDefaultValue.startsWith("L\"")\r
                 && dynamicData.hiiDefaultValue.endsWith("\"");\r
     }\r
-    \r
+\r
+    /**\r
+       Is the string value in ANSCI\r
+       \r
+       @return boolean\r
+    **/\r
     public boolean isHiiDefaultValueASCIIStringType() {\r
         DynamicTokenValue dynamicData = getDefaultSku();\r
     \r
index 20a58ba5f5b6763673db3d6400a59d4000f0dff3..2abcea8bdc691d860e92fda5fee6e357ae259bbb 100644 (file)
@@ -19,8 +19,10 @@ package org.tianocore.build.pcd.entity;
 \r
 \r
 import java.util.UUID;\r
+\r
 import org.tianocore.ModuleTypeDef;\r
 import org.tianocore.build.autogen.CommonDefinition;\r
+import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.pcd.exception.EntityException;\r
 \r
 /**\r
@@ -32,105 +34,65 @@ public class UsageInstance {
     ///\r
     /// This parent that this usage instance belongs to.\r
     ///\r
-    public Token            parentToken;\r
+    public Token                parentToken;\r
 \r
     ///\r
-    /// The name of the module who contains this PCD.\r
-    ///\r
-    public String           moduleName;\r
-\r
-    ///\r
-    /// The GUID of the module who contains this PCD. \r
+    /// ModuleIdentification for Usage Instance\r
     /// \r
-    public UUID             moduleGUID;\r
-\r
-    ///\r
-    /// The name of the package whose module contains this PCD.\r
-    ///\r
-    public String           packageName;\r
+    public ModuleIdentification moduleId;\r
 \r
     ///\r
-    /// The GUID of the package whose module contains this PCD.\r
+    /// Arch also is a key for a UsageInstance\r
     /// \r
-    public UUID             packageGUID;\r
+    public String               arch;\r
 \r
     ///\r
     /// The PCD type defined for module \r
     /// \r
-    public Token.PCD_TYPE   modulePcdType;\r
-\r
-    ///\r
-    /// The arch string of module contains this PCD\r
-    ///\r
-    public String           arch;\r
-\r
-    ///\r
-    /// The version of module contains this PCD\r
-    /// \r
-    public String           version;\r
-\r
-    ///\r
-    /// The module type for this usage instance.\r
-    ///\r
-    public int              moduleType;\r
+    public Token.PCD_TYPE       modulePcdType;\r
 \r
     ///\r
     /// The value of the PCD in this usage instance. \r
     /// \r
-    public String           datum;\r
+    public String               datum;\r
 \r
     ///\r
     /// The maxDatumSize could be different for same PCD in different module\r
     /// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule\r
     /// type.\r
     /// \r
-    public int              maxDatumSize;\r
+    public int                  maxDatumSize;\r
 \r
     ///\r
     /// Autogen string for header file.\r
     ///\r
-    public String           hAutogenStr;\r
+    public String               hAutogenStr;\r
 \r
     ///\r
     /// Auotgen string for C code file.\r
     /// \r
-    public String           cAutogenStr;\r
+    public String               cAutogenStr;\r
 \r
     /**\r
-       Constructure function\r
+       Constructure function for UsageInstance\r
        \r
-       @param parentToken         Member variable.\r
-       @param moduleName          Member variable.\r
-       @param moduleGUID          Member variable.\r
-       @param packageName         Member variable.\r
-       @param packageGUID         Member variable.\r
-       @param moduleType          Member variable.\r
-       @param modulePcdType       Member variable.\r
-       @param arch                Member variable.\r
-       @param version             Member variable.\r
-       @param value               Member variable.\r
-       @param maxDatumSize        Member variable.\r
-     */\r
-    public UsageInstance (Token             parentToken,\r
-                          String            moduleName,\r
-                          UUID              moduleGUID,\r
-                          String            packageName,\r
-                          UUID              packageGUID,\r
-                          int               moduleType,\r
-                          Token.PCD_TYPE    modulePcdType,\r
-                          String            arch,\r
-                          String            version,\r
-                          String            value,\r
-                          int               maxDatumSize) {\r
+       @param parentToken         The token instance for this usgaInstance\r
+       @param id                  The identification for usage instance\r
+       @param modulePcdType       The PCD type for this usage instance\r
+       @param value               The value of this PCD in this usage instance\r
+       @param maxDatumSize        The max datum size of this PCD in this usage\r
+                                  instance.\r
+    **/\r
+    public UsageInstance(Token                 parentToken,\r
+                         ModuleIdentification  moduleId,\r
+                         Token.PCD_TYPE        modulePcdType,\r
+                         String                arch,\r
+                         String                value,\r
+                         int                   maxDatumSize) {\r
         this.parentToken      = parentToken;\r
-        this.moduleName       = moduleName;\r
-        this.moduleGUID       = moduleGUID;\r
-        this.packageName      = packageName;\r
-        this.packageGUID      = packageGUID;\r
-        this.moduleType       = moduleType;\r
+        this.moduleId         = moduleId;\r
         this.modulePcdType    = modulePcdType;\r
         this.arch             = arch;\r
-        this.version          = version;\r
         this.datum            = value;\r
         this.maxDatumSize     = maxDatumSize;\r
     }\r
@@ -138,30 +100,30 @@ public class UsageInstance {
     /**\r
        Get the primary key for usage instance array for every token.\r
        \r
-       @param moduleName      the name of module\r
-       @param moduleGUID      the GUID name of module\r
-       @param packageName     the name of package who contains this module\r
-       @param packageGUID     the GUID name of package\r
-       @param arch            the archtecture string\r
-       @param version         the version of this module\r
+       @param   moduleId      The module Identification for generating primary key\r
+       @param   arch          Arch string\r
        \r
-       @return String         primary key\r
-     */\r
-    public static String getPrimaryKey(String moduleName,  \r
-                                       UUID   moduleGUID,  \r
-                                       String packageName,  \r
-                                       UUID   packageGUID,\r
-                                       String arch,\r
-                                       String version) {\r
+       @retval  String        The primary key for this usage instance\r
+    **/\r
+    public static String getPrimaryKey(ModuleIdentification moduleId,\r
+                                       String               arch) {\r
+        String moduleName   = moduleId.getName();\r
+        String moduleGuid   = moduleId.getGuid();\r
+        String packageName  = moduleId.getPackage().getName();\r
+        String packageGuid  = moduleId.getPackage().getGuid();\r
+        String version      = moduleId.getVersion();\r
+\r
         //\r
         // Because currently transition schema not require write moduleGuid, package Name, Packge GUID in\r
         // <ModuleSA> section, So currently no expect all paramter must be valid.\r
-        return(moduleName                                                              + "_" +\r
-               ((moduleGUID  != null) ? moduleGUID.toString() : "NullModuleGuid")      + "_" +\r
-               ((packageName != null) ? packageName : "NullPackageName")               + "_" +\r
-               ((packageGUID != null) ? packageGUID.toString() : "NullPackageGuid")    + "_" +\r
-               ((arch        != null) ? arch : "NullArch")                             + "_" +\r
-               ((version     != null) ? version : "NullVersion"));\r
+        // BUGBUG: Because currently we can not get version from MSA, So ignore verison.\r
+        // \r
+        return(moduleName                                                                + "_" +\r
+               ((moduleGuid  != null) ? moduleGuid.toLowerCase()    : "NullModuleGuid")  + "_" +\r
+               ((packageName != null) ? packageName                 : "NullPackageName") + "_" +\r
+               ((packageGuid != null) ? packageGuid.toLowerCase()   : "NullPackageGuid") + "_" +\r
+               ((arch        != null) ? arch                        : "NullArch")        + "_" +\r
+               "NullVersion");\r
     }\r
 \r
     /**\r
@@ -170,48 +132,50 @@ public class UsageInstance {
        @return String primary key string\r
     **/\r
     public String getPrimaryKey() {\r
-        return UsageInstance.getPrimaryKey(moduleName, moduleGUID, packageName, packageGUID, arch, version);\r
+        return UsageInstance.getPrimaryKey(moduleId, arch);\r
     }\r
 \r
     /**\r
        Judget whether current module is PEI driver\r
        \r
-       @return boolean\r
-     */\r
+       @return boolean whether current module is PEI driver\r
+    **/\r
     public boolean isPeiPhaseComponent() {\r
+        int moduleType = CommonDefinition.getModuleType(moduleId.getModuleType());\r
+\r
         if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||\r
             (moduleType == CommonDefinition.ModuleTypePeim)) {\r
             return true;\r
         }\r
         return false;\r
     }\r
-  \r
-  public boolean isDxePhaseComponent() {\r
-      //\r
-      // BugBug: May need confirmation on which type of module can\r
-      //         make use of Dynamic(EX) PCD entry.\r
-      //\r
-      if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||\r
-          (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r
-          (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||\r
-          (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||\r
-          (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||\r
-          (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r
-          ) {\r
-          return true;\r
-      }\r
-      return false;\r
-  }\r
 \r
     /**\r
-       Generate autogen string for header file and C code file.\r
+       Judge whether current module is DXE driver.\r
        \r
-       @throws EntityException Fail to generate.\r
+       @return boolean whether current module is DXE driver\r
+    **/\r
+    public boolean isDxePhaseComponent() {\r
+        int moduleType = CommonDefinition.getModuleType(moduleId.getModuleType());\r
+\r
+        if ((moduleType == CommonDefinition.ModuleTypeDxeDriver)        ||\r
+            (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r
+            (moduleType == CommonDefinition.ModuleTypeDxeSalDriver)     ||\r
+            (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver)     ||\r
+            (moduleType == CommonDefinition.ModuleTypeUefiDriver)       ||\r
+            (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r
+            ) {\r
+            return true;\r
+        }\r
+        return false;\r
+    }\r
+\r
+    /**\r
+       Generate autogen string for header file and C code file.\r
        \r
        @param isBuildUsedLibrary  whether the autogen is for library.\r
-     */\r
-    public void generateAutoGen(boolean isBuildUsedLibrary) \r
-        throws EntityException {\r
+    **/\r
+    public void generateAutoGen(boolean isBuildUsedLibrary) {\r
         String  guidStringCName     = null;\r
         boolean isByteArray         = false;\r
         String  printDatum          = null;\r
@@ -221,20 +185,31 @@ public class UsageInstance {
         cAutogenStr = "";\r
 \r
         if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+            //\r
+            // For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen\r
+            // \r
             tokenNumberString =  Long.toString(parentToken.dynamicExTokenNumber, 16);\r
         } else {\r
+            //\r
+            // For Others type PCD, use autogenerated token number to generate autogen\r
+            // \r
             tokenNumberString = Long.toString(parentToken.tokenNumber, 16);\r
         }\r
 \r
-        hAutogenStr += String.format("#define _PCD_TOKEN_%s  0x%s\r\n", \r
-                                     parentToken.cName, tokenNumberString);\r
-        \r
+        hAutogenStr += String.format("#define _PCD_TOKEN_%s  0x%s\r\n", parentToken.cName, tokenNumberString);\r
+\r
+        //\r
+        // Judge the value of this PCD is byte array type\r
+        // \r
         if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
             if (datum.trim().charAt(0) == '{') {\r
                 isByteArray = true;\r
             }\r
         }\r
 \r
+        //\r
+        // "ULL" should be added to value's tail for UINT64 value\r
+        // \r
         if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {\r
             printDatum = this.datum + "ULL";\r
         } else {\r