Patchable VOID* PCD set operation should map LibPatchPcdSetPtr()
and LibPatchPcdSetPtrS() API. This has been done when PCD is used
in driver, but not done when PCD is used in library.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming....@intel.com>
Reviewed-by: Star Zeng <star.z...@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenC.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index 381c14b..76e9fa7 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1019,12 +1019,12 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('extern %s  %s  %s%s;\n' % (Const, Pcd.DatumType, 
PcdVariableName, Array))
             AutoGenH.Append('#define %s  %s%s\n' % (GetModeName, Type, 
PcdVariableName))
 
         if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
             if Pcd.DatumType == 'VOID*':
-                AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  
LibPatchPcdSetPtr(_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, 
(SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName))
-                AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  
LibPatchPcdSetPtrS(_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, 
(SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, 
Pcd.TokenCName))
+                AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  
LibPatchPcdSetPtr((VOID *)_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, 
(SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName))
+                AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  
LibPatchPcdSetPtrS((VOID *)_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, 
(SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, 
Pcd.TokenCName))
             else:
                 AutoGenH.Append('#define %s(Value)  (%s = (Value))\n' % 
(SetModeName, PcdVariableName))
                 AutoGenH.Append('#define %s(Value)  ((%s = (Value)), 
RETURN_SUCCESS) \n' % (SetModeStatusName, PcdVariableName))
         else:
             AutoGenH.Append('//#define %s  ASSERT(FALSE)  // It is not allowed 
to set value for a FIXED_AT_BUILD PCD\n' % SetModeName)
@@ -1141,12 +1141,16 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
             AutoGenH.Append('#define %s(Value)  LibPcdSet%sS(%s, (Value))\n' % 
(SetModeStatusName, DatumSizeLib, PcdTokenName))
     if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE:
         PcdVariableName = '_gPcd_' + 
gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName
         AutoGenH.Append('extern volatile %s _gPcd_BinaryPatch_%s%s;\n' 
%(DatumType, TokenCName, Array) )
         AutoGenH.Append('#define %s  %s_gPcd_BinaryPatch_%s\n' %(GetModeName, 
Type, TokenCName))
-        AutoGenH.Append('#define %s(Value)  (%s = (Value))\n' % (SetModeName, 
PcdVariableName))
-        AutoGenH.Append('#define %s(Value)  ((%s = (Value)), 
RETURN_SUCCESS)\n' % (SetModeStatusName, PcdVariableName))
+        if Pcd.DatumType == 'VOID*':
+            AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  
LibPatchPcdSetPtr((VOID *)_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, 
(SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName))
+            AutoGenH.Append('#define %s(SizeOfBuffer, Buffer)  
LibPatchPcdSetPtrS((VOID *)_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, 
(SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, 
Pcd.TokenCName))
+        else:
+            AutoGenH.Append('#define %s(Value)  (%s = (Value))\n' % 
(SetModeName, PcdVariableName))
+            AutoGenH.Append('#define %s(Value)  ((%s = (Value)), 
RETURN_SUCCESS)\n' % (SetModeStatusName, PcdVariableName))
         
         PcdDataSize = GetPcdSize(Pcd)
         AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, 
PcdDataSize))
         AutoGenH.Append('#define %s %s\n' % 
(GetModeSizeName,PatchPcdSizeVariableName))
         AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName)
-- 
1.9.5.msysgit.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to