Enabling use PcdSetXX macro to set value for PATCHABLE_IN_MODULE, DYNAMIC, DYNAMIC_EX...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 23 Jun 2006 12:00:58 +0000 (12:00 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 23 Jun 2006 12:00:58 +0000 (12:00 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@614 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/PcdLib.h
Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java

index 90e19ba..2f79764 100644 (file)
@@ -20,91 +20,92 @@ Module Name: PcdLib.h
 \r
 #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0)\r
 \r
-#define PcdToken(TokenName)  _PCD_TOKEN_##TokenName\r
+#define PcdToken(TokenName)                 _PCD_TOKEN_##TokenName\r
 \r
 \r
 //\r
 // Feature Flag is in the form of a global constant\r
 //\r
-#define FeaturePcdGet(TokenName)     _PCD_VALUE_##TokenName\r
+#define FeaturePcdGet(TokenName)            _PCD_VALUE_##TokenName\r
 \r
 \r
 //\r
 // Fixed is fixed at build time\r
 //\r
-#define FixedPcdGet8(TokenName)     _PCD_VALUE_##TokenName\r
-#define FixedPcdGet16(TokenName)    _PCD_VALUE_##TokenName\r
-#define FixedPcdGet32(TokenName)    _PCD_VALUE_##TokenName\r
-#define FixedPcdGet64(TokenName)    _PCD_VALUE_##TokenName\r
-#define FixedPcdGetBool(TokenName)  _PCD_VALUE_##TokenName\r
+#define FixedPcdGet8(TokenName)             _PCD_VALUE_##TokenName\r
+#define FixedPcdGet16(TokenName)            _PCD_VALUE_##TokenName\r
+#define FixedPcdGet32(TokenName)            _PCD_VALUE_##TokenName\r
+#define FixedPcdGet64(TokenName)            _PCD_VALUE_##TokenName\r
+#define FixedPcdGetBool(TokenName)          _PCD_VALUE_##TokenName\r
 \r
 \r
 //\r
 // BugBug: This works for strings, but not constants.\r
 //\r
-#define FixedPcdGetPtr(TokenName)    ((VOID *)_PCD_VALUE_##TokenName)\r
+#define FixedPcdGetPtr(TokenName)           ((VOID *)_PCD_VALUE_##TokenName)\r
 \r
 \r
 //\r
 // (Binary) Patch is in the form of a global variable\r
 //\r
-#define PatchPcdGet8(TokenName)     _gPcd_BinaryPatch_##TokenName\r
-#define PatchPcdGet16(TokenName)    _gPcd_BinaryPatch_##TokenName\r
-#define PatchPcdGet32(TokenName)    _gPcd_BinaryPatch_##TokenName\r
-#define PatchPcdGet64(TokenName)    _gPcd_BinaryPatch_##TokenName\r
-#define PatchPcdGetBool(TokenName)  _gPcd_BinaryPatch_##TokenName\r
-#define PatchPcdGetPtr(TokenName)   ((VOID *)_gPcd_BinaryPatch_##TokenName)\r
-\r
-#define PatchPcdSet8(TokenName, Value)     (_gPcd_BinaryPatch_##TokenName = Value)\r
-#define PatchPcdSet16(TokenName, Value)    (_gPcd_BinaryPatch_##TokenName = Value)\r
-#define PatchPcdSet32(TokenName, Value)    (_gPcd_BinaryPatch_##TokenName = Value)\r
-#define PatchPcdSet64(TokenName, Value)    (_gPcd_BinaryPatch_##TokenName = Value)\r
-#define PatchPcdSetBool(TokenName, Value)  (_gPcd_BinaryPatch_##TokenName = Value)\r
-#define PatchPcdSetPtr(TokenName, Size, Buffer)   CopyMem (_gPcd_BinaryPatch_##TokenName, Buffer, Size)\r
+#define PatchPcdGet8(TokenName)             _gPcd_BinaryPatch_##TokenName\r
+#define PatchPcdGet16(TokenName)            _gPcd_BinaryPatch_##TokenName\r
+#define PatchPcdGet32(TokenName)            _gPcd_BinaryPatch_##TokenName\r
+#define PatchPcdGet64(TokenName)            _gPcd_BinaryPatch_##TokenName\r
+#define PatchPcdGetBool(TokenName)          _gPcd_BinaryPatch_##TokenName\r
+#define PatchPcdGetPtr(TokenName)           ((VOID *)_gPcd_BinaryPatch_##TokenName)\r
+\r
+#define PatchPcdSet8(TokenName, Value)      (_gPcd_BinaryPatch_##TokenName = (Value))\r
+#define PatchPcdSet16(TokenName, Value)     (_gPcd_BinaryPatch_##TokenName = (Value))\r
+#define PatchPcdSet32(TokenName, Value)     (_gPcd_BinaryPatch_##TokenName = (Value))\r
+#define PatchPcdSet64(TokenName, Value)     (_gPcd_BinaryPatch_##TokenName = (Value))\r
+#define PatchPcdSetBool(TokenName, Value)   (_gPcd_BinaryPatch_##TokenName = (Value))\r
+#define PatchPcdSetPtr(TokenName, Size, Buffer) \\r
+                                            CopyMem (_gPcd_BinaryPatch_##TokenName, (Buffer), (Size))\r
 \r
 //\r
 // Dynamic is via the protocol with only the TokenNumber as argument\r
 //  It can also be Patch or Fixed type based on a build option\r
 //\r
-#define PcdGet8(TokenName)          _PCD_MODE_8_##TokenName\r
-#define PcdGet16(TokenName)         _PCD_MODE_16_##TokenName\r
-#define PcdGet32(TokenName)         _PCD_MODE_32_##TokenName\r
-#define PcdGet64(TokenName)         _PCD_MODE_64_##TokenName\r
-#define PcdGetPtr(TokenName)        _PCD_MODE_PTR_##TokenName\r
-#define PcdGetBool(TokenName)       _PCD_MODE_BOOL_##TokenName\r
-\r
+#define PcdGet8(TokenName)                  _PCD_GET_MODE_8_##TokenName\r
+#define PcdGet16(TokenName)                 _PCD_GET_MODE_16_##TokenName\r
+#define PcdGet32(TokenName)                 _PCD_GET_MODE_32_##TokenName\r
+#define PcdGet64(TokenName)                 _PCD_GET_MODE_64_##TokenName\r
+#define PcdGetPtr(TokenName)                _PCD_GET_MODE_PTR_##TokenName\r
+#define PcdGetBool(TokenName)               _PCD_GET_MODE_BOOL_##TokenName\r
 \r
 //\r
-// Dynamic Ex is to support binary distribution\r
+// Dynamic Set\r
 //\r
-#define PcdGetEx8(Guid, TokenName)     LibPcdGetEx8 (Guid, _PCD_TOKEN_##TokenName)\r
-#define PcdGetEx16(Guid, TokenName)    LibPcdGetEx16 (Guid, _PCD_TOKEN_##TokenName)\r
-#define PcdGetEx32(Guid, TokenName)    LibPcdGetEx32 (Guid, _PCD_TOKEN_##TokenName)\r
-#define PcdGetEx64(Guid, TokenName)    LibPcdGetEx64 (Guid, _PCD_TOKEN_##TokenName)\r
-#define PcdGetExPtr(Guid, TokenName)   LibPcdGetExPtr (Guid, _PCD_TOKEN_##TokenName)\r
-#define PcdGetExBool(Guid, TokenName)  LibPcdGetExBool (Guid, _PCD_TOKEN_##TokenName)\r
-\r
+#define PcdSet8(TokenName, Value)           _PCD_SET_MODE_8_##TokenName     ((Value))\r
+#define PcdSet16(TokenName, Value)          _PCD_SET_MODE_16_##TokenName    ((Value))\r
+#define PcdSet32(TokenName, Value)          _PCD_SET_MODE_32_##TokenName    ((Value))\r
+#define PcdSet64(TokenName, Value)          _PCD_SET_MODE_64_##TokenName    ((Value))\r
+#define PcdSetPtr(TokenName, SizeOfBuffer, Buffer) \\r
+                                            _PCD_SET_MODE_PTR_##TokenName   ((SizeOfBuffer), (Buffer))\r
+#define PcdSetBool(TokenName, Value)        _PCD_SET_MODE_BOOL_##TokenName  ((Value))\r
 \r
 //\r
-// Dynamic Set\r
+// Dynamic Ex is to support binary distribution\r
 //\r
-#define PcdSet8(TokenName, Value)       LibPcdSet8   (_PCD_TOKEN_##TokenName, Value)\r
-#define PcdSet16(TokenName, Value)      LibPcdSet16  (_PCD_TOKEN_##TokenName, Value)\r
-#define PcdSet32(TokenName, Value)      LibPcdSet32  (_PCD_TOKEN_##TokenName, Value)\r
-#define PcdSet64(TokenName, Value)      LibPcdSet64  (_PCD_TOKEN_##TokenName, Value)\r
-#define PcdSetPtr(TokenName, SizeOfBuffer, Buffer)     LibPcdSetPtr (_PCD_TOKEN_##TokenName, SizeOfBuffer, Buffer)\r
-#define PcdSetBool(TokenName, Value)    LibPcdSetBool(_PCD_TOKEN_##TokenName, Value)\r
-\r
+#define PcdGetEx8(Guid, TokenName)          LibPcdGetEx8    ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetEx16(Guid, TokenName)         LibPcdGetEx16   ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetEx32(Guid, TokenName)         LibPcdGetEx32   ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetEx64(Guid, TokenName)         LibPcdGetEx64   ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetExPtr(Guid, TokenName)        LibPcdGetExPtr  ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetExBool(Guid, TokenName)       LibPcdGetExBool ((Guid), _PCD_TOKEN_##TokenName)\r
 \r
 //\r
 // Dynamic Set Ex\r
 //\r
-#define PcdSetEx8(Guid, TokenName, Value)      LibPcdSetEx8   (Guid, _PCD_TOKEN_##TokenName, Value)\r
-#define PcdSetEx16(Guid, TokenName, Value)     LibPcdSetEx16  (Guid, _PCD_TOKEN_##TokenName, Value)\r
-#define PcdSetEx32(Guid, TokenName, Value)     LibPcdSetEx32  (Guid, _PCD_TOKEN_##TokenName, Value)\r
-#define PcdSetEx64(Guid, TokenName, Value)     LibPcdSetEx64  (Guid, _PCD_TOKEN_##TokenName, Value)\r
-#define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer)    LibPcdSetExPtr (Guid, _PCD_TOKEN_##TokenName, SizeOfBuffer, Buffer)\r
-#define PcdSetExBool(Guid, TokenName, Value)   LibPcdSetExBool(Guid, _PCD_TOKEN_##TokenName, Value)\r
+#define PcdSetEx8(Guid, TokenName, Value)   LibPcdSetEx8   ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetEx16(Guid, TokenName, Value)  LibPcdSetEx16  ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetEx32(Guid, TokenName, Value)  LibPcdSetEx32  ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetEx64(Guid, TokenName, Value)  LibPcdSetEx64  ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \\r
+                                            LibPcdSetExPtr ((Guid), _PCD_TOKEN_##TokenName, (SizeOfBuffer), (Buffer))\r
+#define PcdSetExBool(Guid, TokenName, Value) \\r
+                                            LibPcdSetExBool((Guid), _PCD_TOKEN_##TokenName, (Value))\r
 \r
 \r
 /**\r
index 85806b4..baf8757 100644 (file)
@@ -242,10 +242,13 @@ public class UsageInstance {
         case FEATURE_FLAG:\r
             hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
                                          parentToken.cName);\r
-            hAutogenStr += String.format("#define _PCD_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n",\r
+            hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n",\r
                                          parentToken.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
+                                         parentToken.cName);\r
 \r
             if (!isBuildUsedLibrary) {\r
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
@@ -260,7 +263,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_MODE_%s_%s  &_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
@@ -268,12 +271,15 @@ 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_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
+                                         parentToken.cName);\r
             if (!isBuildUsedLibrary) {\r
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
                                              parentToken.cName, \r
@@ -294,7 +300,7 @@ public class UsageInstance {
             if (isByteArray) {\r
                 hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
                                              parentToken.cName);\r
-                hAutogenStr += String.format("#define _PCD_MODE_%s_%s  &_gPcd_BinaryPatch_%s\r\n",\r
+                hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  (VOID*)_gPcd_BinaryPatch_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);  \r
@@ -302,12 +308,27 @@ public class UsageInstance {
                 hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
                                              Token.getAutogendatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
-                hAutogenStr += String.format("#define _PCD_MODE_%s_%s  _gPcd_BinaryPatch_%s\r\n",\r
+                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
             }\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
+                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n",\r
+                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName,\r
+                                             parentToken.cName);\r
+            } else {\r
+                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",\r
+                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName,\r
+                                             parentToken.cName);\r
+            }\r
+            \r
             if (!isBuildUsedLibrary) {\r
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
                                              parentToken.cName, \r
@@ -326,23 +347,52 @@ public class UsageInstance {
 \r
             break;\r
         case DYNAMIC:\r
-            hAutogenStr += String.format("#define _PCD_MODE_%s_%s  LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r
+            hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
                                          Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
+            if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer)  LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
+                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName,\r
+                                             Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName);\r
+            } else {\r
+                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value)  LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",\r
+                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName,\r
+                                             Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName);\r
+            }\r
             break;\r
         case DYNAMIC_EX:\r
             guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
                               parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
-                                            \r
-            hAutogenStr += String.format("#define _PCD_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r
+\r
+            hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
                                          Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
                                          guidStringCName,\r
                                          parentToken.cName);\r
 \r
+            if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
+                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName,\r
+                                             Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+                                             guidStringCName,\r
+                                             parentToken.cName);\r
+            } else {\r
+                hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",\r
+                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                             parentToken.cName,\r
+                                             Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+                                             guidStringCName,\r
+                                             parentToken.cName);\r
+\r
+            }\r
             break;\r
         }\r
     }\r