Fix track EDKT213: PCD value size should be specificed when generate const variable...
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / pcd / entity / UsageInstance.java
index 03499e6..2484453 100644 (file)
@@ -327,7 +327,7 @@ public class UsageInstance {
             }\r
             break;\r
         case PATCHABLE_IN_MODULE:\r
-            if (isByteArray) {\r
+            if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
                 //\r
                 // Example autogen string for following generation:\r
                 // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken[];"\r
@@ -342,6 +342,21 @@ public class UsageInstance {
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r
+                // \r
+                hAutogenStr += String.format("#define _PCD_PATCHABLE_%s_SIZE %d\r\n",\r
+                                             parentToken.cName,\r
+                                             parentToken.datumSize);\r
+                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) "+\r
+                                             "LibPatchPcdSetPtr (_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, "+\r
+                                             "(SizeOfBuffer), (Buffer))\r\n",\r
+                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName,\r
+                                             parentToken.cName,\r
+                                             parentToken.cName);\r
+\r
             } else {\r
                 //\r
                 // Example autogen string for following generation:\r
@@ -358,27 +373,6 @@ public class UsageInstance {
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\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
-            if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
-                //\r
-                // Example autogen string for following generation:\r
-                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r
-                // \r
-                hAutogenStr += String.format("#define _PCD_PATCHABLE_%s_SIZE %d\r\n",\r
-                                             parentToken.cName,\r
-                                             parentToken.datumSize);\r
-                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) "+\r
-                                             "LibPatchPcdSetPtr (_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, "+\r
-                                             "(SizeOfBuffer), (Buffer))\r\n",\r
-                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
-                                             parentToken.cName,\r
-                                             parentToken.cName,\r
-                                             parentToken.cName);\r
-            } else {\r
                 //\r
                 // Example autogen string for following generation:\r
                 // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) (_gPcd_BinaryPatch_PcdSampleToken = (Value))"\r
@@ -390,6 +384,9 @@ public class UsageInstance {
             }\r
 \r
             if (!isBuildUsedLibrary) {\r
+                if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                    printDatum = parentToken.getByteArrayForPointerDatum(printDatum);\r
+                }\r
                 //\r
                 // Example autogen string for following generation:\r
                 // "#define _PCD_VALUE_PcdSampleToken   0x111"\r
@@ -397,7 +394,7 @@ public class UsageInstance {
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                              parentToken.cName,\r
                                              printDatum);\r
-                if (isByteArray) {\r
+                if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
                     //\r
                     // Example autogen string for following generation:\r
                     // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r