]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageInstance.java
Abstract the logic of Platform pcd preprocess according to FPD file to a class. And...
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / pcd / entity / UsageInstance.java
index a961d8807da552204800f87c4460763e0c41a894..6fc66055eb8043bd8ba80e98cb22e1af4044de43 100644 (file)
@@ -4,26 +4,21 @@
   This class indicate an usage instance for a PCD token. This instance maybe a module\r
   or platform setting. When a module produce or cosume a PCD token, then this module\r
   is an usage instance for this PCD token.\r
\r
+\r
 Copyright (c) 2006, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
\r
+\r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-**/  \r
+**/\r
 package org.tianocore.pcd.entity;\r
 \r
-\r
-import java.util.UUID;\r
-\r
-import org.tianocore.ModuleTypeDef;\r
 import org.tianocore.pcd.entity.CommonDefinition;\r
 import org.tianocore.pcd.entity.UsageIdentification;\r
-import org.tianocore.pcd.exception.EntityException;\r
 \r
 /**\r
   This class indicate an usage instance for a PCD token. This instance maybe a module\r
@@ -38,29 +33,29 @@ public class UsageInstance {
 \r
     ///\r
     /// ModuleIdentification for Usage Instance\r
-    /// \r
+    ///\r
     public UsageIdentification  usageId;\r
 \r
     ///\r
     /// Arch also is a key for a UsageInstance\r
-    /// \r
+    ///\r
     public String               arch;\r
 \r
     ///\r
-    /// The PCD type defined for module \r
-    /// \r
+    /// The PCD type defined for module\r
+    ///\r
     public Token.PCD_TYPE       modulePcdType;\r
 \r
     ///\r
-    /// The value of the PCD in this usage instance. \r
-    /// \r
+    /// The value of the PCD in this usage instance.\r
+    ///\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
+    ///\r
     public int                  maxDatumSize;\r
 \r
     ///\r
@@ -70,12 +65,12 @@ public class UsageInstance {
 \r
     ///\r
     /// Auotgen string for C code file.\r
-    /// \r
+    ///\r
     public String               cAutogenStr;\r
 \r
     /**\r
        Constructure function for UsageInstance\r
-       \r
+\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
@@ -97,9 +92,9 @@ public class UsageInstance {
 \r
     /**\r
        Get the primary key for usage instance array for every token.\r
-       \r
+\r
        @param   usageId       The identification of UsageInstance\r
-       \r
+\r
        @retval  String        The primary key for this usage instance\r
     **/\r
     public static String getPrimaryKey(UsageIdentification usageId) {\r
@@ -108,7 +103,7 @@ public class UsageInstance {
 \r
     /**\r
        Get primary key string for this usage instance\r
-       \r
+\r
        @return String primary key string\r
     **/\r
     public String getPrimaryKey() {\r
@@ -117,7 +112,7 @@ public class UsageInstance {
 \r
     /**\r
        Judget whether current module is PEI driver\r
-       \r
+\r
        @return boolean whether current module is PEI driver\r
     **/\r
     public boolean isPeiPhaseComponent() {\r
@@ -132,7 +127,7 @@ public class UsageInstance {
 \r
     /**\r
        Judge whether current module is DXE driver.\r
-       \r
+\r
        @return boolean whether current module is DXE driver\r
     **/\r
     public boolean isDxePhaseComponent() {\r
@@ -152,7 +147,7 @@ public class UsageInstance {
 \r
     /**\r
        Generate autogen string for header file and C code file.\r
-       \r
+\r
        @param isBuildUsedLibrary  whether the autogen is for library.\r
     **/\r
     public void generateAutoGen(boolean isBuildUsedLibrary) {\r
@@ -167,12 +162,12 @@ public class UsageInstance {
         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
+            //\r
             tokenNumberString =  Long.toString(parentToken.dynamicExTokenNumber, 16);\r
         } else {\r
             //\r
             // For Others type PCD, use autogenerated token number to generate autogen\r
-            // \r
+            //\r
             tokenNumberString = Long.toString(parentToken.tokenNumber, 16);\r
         }\r
 \r
@@ -180,7 +175,7 @@ public class UsageInstance {
 \r
         //\r
         // Judge the value of this PCD is byte array type\r
-        // \r
+        //\r
         if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
             if (datum.trim().charAt(0) == '{') {\r
                 isByteArray = true;\r
@@ -189,7 +184,7 @@ public class UsageInstance {
 \r
         //\r
         // "ULL" should be added to value's tail for UINT64 value\r
-        // \r
+        //\r
         if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {\r
             printDatum = this.datum + "ULL";\r
         } else {\r
@@ -198,19 +193,19 @@ public class UsageInstance {
 \r
         switch (modulePcdType) {\r
         case FEATURE_FLAG:\r
-            hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
+            hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",\r
                                          parentToken.cName);\r
             hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n",\r
-                                         parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                         Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
                                          parentToken.cName);\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
-                                         parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                         Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
 \r
             if (!isBuildUsedLibrary) {\r
-                hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
-                                             parentToken.cName, \r
+                hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
+                                             parentToken.cName,\r
                                              printDatum);\r
                 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                              parentToken.cName,\r
@@ -221,7 +216,7 @@ public class UsageInstance {
             if (isByteArray) {\r
                 hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
                                              parentToken.cName);\r
-                hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  (VOID*)_gPcd_FixedAtBuild_%s\r\n", \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
@@ -229,27 +224,27 @@ public class UsageInstance {
                 hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
                                              Token.getAutogendatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
-                hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n", \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
             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
-                                         parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                         Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
             if (!isBuildUsedLibrary) {\r
                 if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
                     if (isByteArray) {\r
-                        hAutogenStr += String.format("#define _PCD_VALUE_%s   (VOID*)_gPcd_FixedAtBuild_%s\r\n", \r
-                                                     parentToken.cName, \r
+                        hAutogenStr += String.format("#define _PCD_VALUE_%s   (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
+                                                     parentToken.cName,\r
                                                      parentToken.cName);\r
                         cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r
                                                      parentToken.cName,\r
                                                      printDatum);\r
                     } else {\r
-                        hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
-                                                     parentToken.cName, \r
+                        hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
+                                                     parentToken.cName,\r
                                                      printDatum);\r
                         cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                                      Token.getAutogendatumTypeString(parentToken.datumType),\r
@@ -257,8 +252,8 @@ public class UsageInstance {
                                                      parentToken.cName);\r
                     }\r
                 } else {\r
-                    hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
-                                                 parentToken.cName, \r
+                    hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
+                                                 parentToken.cName,\r
                                                  printDatum);\r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                                  Token.getAutogendatumTypeString(parentToken.datumType),\r
@@ -274,7 +269,7 @@ public class UsageInstance {
                 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
+                                             parentToken.cName);\r
             } else {\r
                 hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
                                              Token.getAutogendatumTypeString(parentToken.datumType),\r
@@ -282,12 +277,12 @@ public class UsageInstance {
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_BinaryPatch_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
-                                             parentToken.cName);                \r
+                                             parentToken.cName);\r
             }\r
 \r
             //\r
             // Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro\r
-            // \r
+            //\r
             if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\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
@@ -299,10 +294,10 @@ public class UsageInstance {
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             }\r
-            \r
+\r
             if (!isBuildUsedLibrary) {\r
-                hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
-                                             parentToken.cName, \r
+                hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
+                                             parentToken.cName,\r
                                              printDatum);\r
                 if (isByteArray) {\r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",\r
@@ -370,7 +365,7 @@ public class UsageInstance {
 \r
     /**\r
       Get the autogen string for header file.\r
-      \r
+\r
       @return The string of header file.\r
     **/\r
     public String getHAutogenStr() {\r
@@ -379,7 +374,7 @@ public class UsageInstance {
 \r
     /**\r
       Get the autogen string for C code file.\r
-      \r
+\r
       @return The string of C Code file.\r
     **/\r
     public String getCAutogenStr() {\r