]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add two PcdApi for Patch VOID* PCD set operation.
authorLiming Gao <liming.gao@intel.com>
Mon, 24 Aug 2015 05:01:11 +0000 (05:01 +0000)
committerlgao4 <lgao4@Edk2>
Mon, 24 Aug 2015 05:01:11 +0000 (05:01 +0000)
Two new APIs LibPatchPcdSetPtrAndSize() and LibPatchPcdSetPtrAndSizeS()
are added to catch the size of the updated VOID* PCD value buffer, then
PcdGetSize() API can return the actual size.

Update three PcdLib instances to implement these two APIs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18269 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/PcdLib.h
MdePkg/Library/BasePcdLibNull/PcdLib.c
MdePkg/Library/DxePcdLib/DxePcdLib.c
MdePkg/Library/PeiPcdLib/PeiPcdLib.c

index ce759fea2d35a65ad82460a12dcde1fac3ecfb1c..ad8a70082acb4c8b1c9fca159a72ce55249289ee 100644 (file)
@@ -342,8 +342,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 #define PatchPcdSetPtr(TokenName, Size, Buffer) \\r
-                                            LibPatchPcdSetPtr (                        \\r
-                                              _gPcd_BinaryPatch_##TokenName,           \\r
+                                            LibPatchPcdSetPtrAndSize (                 \\r
+                                              (VOID *)_gPcd_BinaryPatch_##TokenName,   \\r
+                                              &_gPcd_BinaryPatch_Size_##TokenName,     \\r
                                               (UINTN)_PCD_PATCHABLE_##TokenName##_SIZE, \\r
                                               (Size),                                  \\r
                                               (Buffer)                                 \\r
@@ -2056,7 +2057,7 @@ LibPcdGetNextTokenSpace (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is \r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -2068,7 +2069,7 @@ LibPcdGetNextTokenSpace (
 VOID *\r
 EFIAPI\r
 LibPatchPcdSetPtr (\r
-  IN        VOID        *PatchVariable,\r
+  OUT        VOID       *PatchVariable,\r
   IN        UINTN       MaximumDatumSize,\r
   IN OUT    UINTN       *SizeOfBuffer,\r
   IN CONST  VOID        *Buffer\r
@@ -2088,7 +2089,7 @@ LibPatchPcdSetPtr (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -2100,7 +2101,77 @@ LibPatchPcdSetPtr (
 RETURN_STATUS\r
 EFIAPI\r
 LibPatchPcdSetPtrS (\r
-  IN       VOID     *PatchVariable,\r
+  OUT      VOID     *PatchVariable,\r
+  IN       UINTN    MaximumDatumSize,\r
+  IN OUT   UINTN    *SizeOfBuffer,\r
+  IN CONST VOID     *Buffer\r
+  );\r
+\r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+  \r
+  Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
+  and SizeOfBuffer. Buffer is returned.  If SizeOfBuffer is greater than \r
+  MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
+  NULL to indicate that the set operation was not actually performed.  \r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
+  MaximumDatumSize and NULL must be returned.\r
+  \r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return Return the pointer to the Buffer that was set.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSize (\r
+  OUT       VOID        *PatchVariable,\r
+  OUT       UINTN       *SizeOfPatchVariable,\r
+  IN        UINTN       MaximumDatumSize,\r
+  IN OUT    UINTN       *SizeOfBuffer,\r
+  IN CONST  VOID        *Buffer\r
+  );\r
+\r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+\r
+  Sets the PCD entry specified by PatchVariable to the value specified\r
+  by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
+  then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
+  to indicate that the set operation was not actually performed.\r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
+  MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
+\r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSizeS (\r
+  OUT      VOID     *PatchVariable,\r
+  OUT      UINTN    *SizeOfPatchVariable,\r
   IN       UINTN    MaximumDatumSize,\r
   IN OUT   UINTN    *SizeOfBuffer,\r
   IN CONST VOID     *Buffer\r
index e5d1627fed13f8d66b4677aa5ef3fbbdf0a50caf..5d914ada561c6abc62122134e4c587b8a51be63e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   A emptry template implementation of PCD Library.\r
 \r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
   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
@@ -1220,7 +1220,7 @@ LibPcdGetNextTokenSpace (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is \r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -1232,7 +1232,7 @@ LibPcdGetNextTokenSpace (
 VOID *\r
 EFIAPI\r
 LibPatchPcdSetPtr (\r
-  IN        VOID        *PatchVariable,\r
+  OUT       VOID        *PatchVariable,\r
   IN        UINTN       MaximumDatumSize,\r
   IN OUT    UINTN       *SizeOfBuffer,\r
   IN CONST  VOID        *Buffer\r
@@ -1270,7 +1270,7 @@ LibPatchPcdSetPtr (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -1282,7 +1282,7 @@ LibPatchPcdSetPtr (
 RETURN_STATUS\r
 EFIAPI\r
 LibPatchPcdSetPtrS (\r
-  IN       VOID     *PatchVariable,\r
+  OUT      VOID     *PatchVariable,\r
   IN       UINTN    MaximumDatumSize,\r
   IN OUT   UINTN    *SizeOfBuffer,\r
   IN CONST VOID     *Buffer\r
@@ -1306,6 +1306,116 @@ LibPatchPcdSetPtrS (
   return RETURN_SUCCESS;\r
 }\r
 \r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+  \r
+  Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
+  and SizeOfBuffer.  Buffer is returned.  If SizeOfBuffer is greater than \r
+  MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
+  NULL to indicate that the set operation was not actually performed.  \r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
+  MaximumDatumSize and NULL must be returned.\r
+  \r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return Return the pointer to the buffer been set.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSize (\r
+  OUT       VOID        *PatchVariable,\r
+  OUT       UINTN       *SizeOfPatchVariable,\r
+  IN        UINTN       MaximumDatumSize,\r
+  IN OUT    UINTN       *SizeOfBuffer,\r
+  IN CONST  VOID        *Buffer\r
+  )\r
+{\r
+  ASSERT (PatchVariable != NULL);\r
+  ASSERT (SizeOfPatchVariable != NULL);\r
+  ASSERT (SizeOfBuffer  != NULL);\r
+  \r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+      (*SizeOfBuffer == MAX_ADDRESS)) {\r
+    *SizeOfBuffer = MaximumDatumSize;\r
+    return NULL;\r
+  }\r
+    \r
+  CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+  *SizeOfPatchVariable = *SizeOfBuffer;\r
+  \r
+  return (VOID *) Buffer;\r
+}\r
+\r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+\r
+  Sets the PCD entry specified by PatchVariable to the value specified\r
+  by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
+  then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
+  to indicate that the set operation was not actually performed.\r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
+  MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
+\r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSizeS (\r
+  OUT      VOID     *PatchVariable,\r
+  OUT      UINTN    *SizeOfPatchVariable,\r
+  IN       UINTN    MaximumDatumSize,\r
+  IN OUT   UINTN    *SizeOfBuffer,\r
+  IN CONST VOID     *Buffer\r
+  )\r
+{\r
+  ASSERT (PatchVariable != NULL);\r
+  ASSERT (SizeOfPatchVariable != NULL);\r
+  ASSERT (SizeOfBuffer  != NULL);\r
+  \r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+      (*SizeOfBuffer == MAX_ADDRESS)) {\r
+    *SizeOfBuffer = MaximumDatumSize;\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+\r
+  CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+  *SizeOfPatchVariable = *SizeOfBuffer;\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
 /**\r
   Retrieve additional information associated with a PCD token.\r
 \r
index 431ee7206aa07a2074f6efd7574687ea4c4c9f5b..79f769557b80213c26f47084a2d30453e4f43f4e 100644 (file)
@@ -1362,7 +1362,7 @@ LibPcdGetNextTokenSpace (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is \r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -1374,7 +1374,7 @@ LibPcdGetNextTokenSpace (
 VOID *\r
 EFIAPI\r
 LibPatchPcdSetPtr (\r
-  IN        VOID        *PatchVariable,\r
+  OUT       VOID        *PatchVariable,\r
   IN        UINTN       MaximumDatumSize,\r
   IN OUT    UINTN       *SizeOfBuffer,\r
   IN CONST  VOID        *Buffer\r
@@ -1412,7 +1412,7 @@ LibPatchPcdSetPtr (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -1424,7 +1424,7 @@ LibPatchPcdSetPtr (
 RETURN_STATUS\r
 EFIAPI\r
 LibPatchPcdSetPtrS (\r
-  IN       VOID     *PatchVariable,\r
+  OUT       VOID     *PatchVariable,\r
   IN       UINTN    MaximumDatumSize,\r
   IN OUT   UINTN    *SizeOfBuffer,\r
   IN CONST VOID     *Buffer\r
@@ -1448,6 +1448,117 @@ LibPatchPcdSetPtrS (
   return RETURN_SUCCESS;\r
 }\r
 \r
+\r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+  \r
+  Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
+  and SizeOfBuffer.  Buffer is returned.  If SizeOfBuffer is greater than \r
+  MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
+  NULL to indicate that the set operation was not actually performed.  \r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
+  MaximumDatumSize and NULL must be returned.\r
+  \r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return Return the pointer to the buffer been set.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSize (\r
+  OUT       VOID        *PatchVariable,\r
+  OUT       UINTN       *SizeOfPatchVariable,\r
+  IN        UINTN       MaximumDatumSize,\r
+  IN OUT    UINTN       *SizeOfBuffer,\r
+  IN CONST  VOID        *Buffer\r
+  )\r
+{\r
+  ASSERT (PatchVariable != NULL);\r
+  ASSERT (SizeOfPatchVariable != NULL);\r
+  ASSERT (SizeOfBuffer  != NULL);\r
+  \r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+      (*SizeOfBuffer == MAX_ADDRESS)) {\r
+    *SizeOfBuffer = MaximumDatumSize;\r
+    return NULL;\r
+  }\r
+    \r
+  CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+  *SizeOfPatchVariable = *SizeOfBuffer;\r
+  \r
+  return (VOID *) Buffer;\r
+}\r
+\r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+\r
+  Sets the PCD entry specified by PatchVariable to the value specified\r
+  by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
+  then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
+  to indicate that the set operation was not actually performed.\r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
+  MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
+\r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSizeS (\r
+  OUT      VOID     *PatchVariable,\r
+  OUT      UINTN    *SizeOfPatchVariable,\r
+  IN       UINTN    MaximumDatumSize,\r
+  IN OUT   UINTN    *SizeOfBuffer,\r
+  IN CONST VOID     *Buffer\r
+  )\r
+{\r
+  ASSERT (PatchVariable != NULL);\r
+  ASSERT (SizeOfPatchVariable != NULL);\r
+  ASSERT (SizeOfBuffer  != NULL);\r
+  \r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+      (*SizeOfBuffer == MAX_ADDRESS)) {\r
+    *SizeOfBuffer = MaximumDatumSize;\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+\r
+  CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+  *SizeOfPatchVariable = *SizeOfBuffer;\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
 /**\r
   Retrieve additional information associated with a PCD token.\r
 \r
index 3d7139682a00efaece47e9ba978c377d70ec764a..53e8ad6c00175c2b261a6a8f010dba6ec4c51adc 100644 (file)
@@ -1363,7 +1363,7 @@ LibPcdGetNextTokenSpace (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is \r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -1375,7 +1375,7 @@ LibPcdGetNextTokenSpace (
 VOID *\r
 EFIAPI\r
 LibPatchPcdSetPtr (\r
-  IN        VOID        *PatchVariable,\r
+  OUT       VOID        *PatchVariable,\r
   IN        UINTN       MaximumDatumSize,\r
   IN OUT    UINTN       *SizeOfBuffer,\r
   IN CONST  VOID        *Buffer\r
@@ -1413,7 +1413,7 @@ LibPatchPcdSetPtr (
   If SizeOfBuffer is NULL, then ASSERT().\r
   If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
 \r
-  @param[in] PatchVariable      A pointer to the global variable in a module that is\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
                                 the target of the set operation.\r
   @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
   @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
@@ -1425,7 +1425,7 @@ LibPatchPcdSetPtr (
 RETURN_STATUS\r
 EFIAPI\r
 LibPatchPcdSetPtrS (\r
-  IN       VOID     *PatchVariable,\r
+  OUT      VOID     *PatchVariable,\r
   IN       UINTN    MaximumDatumSize,\r
   IN OUT   UINTN    *SizeOfBuffer,\r
   IN CONST VOID     *Buffer\r
@@ -1449,6 +1449,117 @@ LibPatchPcdSetPtrS (
   return RETURN_SUCCESS;\r
 }\r
 \r
+\r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+  \r
+  Sets the PCD entry specified by PatchVariable to the value specified by Buffer \r
+  and SizeOfBuffer.  Buffer is returned.  If SizeOfBuffer is greater than \r
+  MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return \r
+  NULL to indicate that the set operation was not actually performed.  \r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to \r
+  MaximumDatumSize and NULL must be returned.\r
+  \r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is \r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return Return the pointer to the buffer been set.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSize (\r
+  OUT       VOID        *PatchVariable,\r
+  OUT       UINTN       *SizeOfPatchVariable,\r
+  IN        UINTN       MaximumDatumSize,\r
+  IN OUT    UINTN       *SizeOfBuffer,\r
+  IN CONST  VOID        *Buffer\r
+  )\r
+{\r
+  ASSERT (PatchVariable != NULL);\r
+  ASSERT (SizeOfPatchVariable != NULL);\r
+  ASSERT (SizeOfBuffer  != NULL);\r
+  \r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+      (*SizeOfBuffer == MAX_ADDRESS)) {\r
+    *SizeOfBuffer = MaximumDatumSize;\r
+    return NULL;\r
+  }\r
+    \r
+  CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+  *SizeOfPatchVariable = *SizeOfBuffer;\r
+  \r
+  return (VOID *) Buffer;\r
+}\r
+\r
+/**\r
+  Sets a value and size of a patchable PCD entry that is type pointer.\r
+\r
+  Sets the PCD entry specified by PatchVariable to the value specified\r
+  by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,\r
+  then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER\r
+  to indicate that the set operation was not actually performed.\r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to\r
+  MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.\r
+\r
+  If PatchVariable is NULL, then ASSERT().\r
+  If SizeOfPatchVariable is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[out] PatchVariable     A pointer to the global variable in a module that is\r
+                                the target of the set operation.\r
+  @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.\r
+  @param[in] MaximumDatumSize   The maximum size allowed for the PCD entry specified by PatchVariable.\r
+  @param[in, out] SizeOfBuffer  A pointer to the size, in bytes, of Buffer.\r
+  @param[in] Buffer             A pointer to the buffer to used to set the target variable.\r
+  \r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPatchPcdSetPtrAndSizeS (\r
+  OUT      VOID     *PatchVariable,\r
+  OUT      UINTN    *SizeOfPatchVariable,\r
+  IN       UINTN    MaximumDatumSize,\r
+  IN OUT   UINTN    *SizeOfBuffer,\r
+  IN CONST VOID     *Buffer\r
+  )\r
+{\r
+  ASSERT (PatchVariable != NULL);\r
+  ASSERT (SizeOfPatchVariable != NULL);\r
+  ASSERT (SizeOfBuffer  != NULL);\r
+  \r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  if ((*SizeOfBuffer > MaximumDatumSize) ||\r
+      (*SizeOfBuffer == MAX_ADDRESS)) {\r
+    *SizeOfBuffer = MaximumDatumSize;\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+\r
+  CopyMem (PatchVariable, Buffer, *SizeOfBuffer);\r
+  *SizeOfPatchVariable = *SizeOfBuffer;\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
 /**\r
   Retrieve additional information associated with a PCD token.\r
 \r