summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2015-08-24 05:01:11 +0000
committerlgao4 <lgao4@Edk2>2015-08-24 05:01:11 +0000
commitf8308f0ad14dd4e078927f2da17283a8f47f0566 (patch)
tree36bf2f36c0180ae6bb3ee85c13d96e3e9f68dafe /MdePkg
parentbf8e99a4a049140720b0439c75d6f8d3f27cdadc (diff)
downloadedk2-platforms-f8308f0ad14dd4e078927f2da17283a8f47f0566.tar.xz
MdePkg: Add two PcdApi for Patch VOID* PCD set operation.
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
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Library/PcdLib.h83
-rw-r--r--MdePkg/Library/BasePcdLibNull/PcdLib.c120
-rw-r--r--MdePkg/Library/DxePcdLib/DxePcdLib.c119
-rw-r--r--MdePkg/Library/PeiPcdLib/PeiPcdLib.c119
4 files changed, 422 insertions, 19 deletions
diff --git a/MdePkg/Include/Library/PcdLib.h b/MdePkg/Include/Library/PcdLib.h
index ce759fea2d..ad8a70082a 100644
--- a/MdePkg/Include/Library/PcdLib.h
+++ b/MdePkg/Include/Library/PcdLib.h
@@ -342,8 +342,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#define PatchPcdSetPtr(TokenName, Size, Buffer) \
- LibPatchPcdSetPtr ( \
- _gPcd_BinaryPatch_##TokenName, \
+ LibPatchPcdSetPtrAndSize ( \
+ (VOID *)_gPcd_BinaryPatch_##TokenName, \
+ &_gPcd_BinaryPatch_Size_##TokenName, \
(UINTN)_PCD_PATCHABLE_##TokenName##_SIZE, \
(Size), \
(Buffer) \
@@ -2056,7 +2057,7 @@ LibPcdGetNextTokenSpace (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -2068,7 +2069,7 @@ LibPcdGetNextTokenSpace (
VOID *
EFIAPI
LibPatchPcdSetPtr (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
@@ -2088,7 +2089,7 @@ LibPatchPcdSetPtr (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -2100,7 +2101,77 @@ LibPatchPcdSetPtr (
RETURN_STATUS
EFIAPI
LibPatchPcdSetPtrS (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ );
+
+/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified by Buffer
+ and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
+ MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
+ NULL to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and NULL must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return Return the pointer to the Buffer that was set.
+
+**/
+VOID *
+EFIAPI
+LibPatchPcdSetPtrAndSize (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ );
+
+/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified
+ by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
+ then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
+ to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return The status of the set operation.
+
+**/
+RETURN_STATUS
+EFIAPI
+LibPatchPcdSetPtrAndSizeS (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
diff --git a/MdePkg/Library/BasePcdLibNull/PcdLib.c b/MdePkg/Library/BasePcdLibNull/PcdLib.c
index e5d1627fed..5d914ada56 100644
--- a/MdePkg/Library/BasePcdLibNull/PcdLib.c
+++ b/MdePkg/Library/BasePcdLibNull/PcdLib.c
@@ -1,7 +1,7 @@
/** @file
A emptry template implementation of PCD Library.
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1220,7 +1220,7 @@ LibPcdGetNextTokenSpace (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -1232,7 +1232,7 @@ LibPcdGetNextTokenSpace (
VOID *
EFIAPI
LibPatchPcdSetPtr (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
@@ -1270,7 +1270,7 @@ LibPatchPcdSetPtr (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -1282,7 +1282,7 @@ LibPatchPcdSetPtr (
RETURN_STATUS
EFIAPI
LibPatchPcdSetPtrS (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
@@ -1307,6 +1307,116 @@ LibPatchPcdSetPtrS (
}
/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified by Buffer
+ and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
+ MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
+ NULL to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and NULL must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return Return the pointer to the buffer been set.
+
+**/
+VOID *
+EFIAPI
+LibPatchPcdSetPtrAndSize (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ )
+{
+ ASSERT (PatchVariable != NULL);
+ ASSERT (SizeOfPatchVariable != NULL);
+ ASSERT (SizeOfBuffer != NULL);
+
+ if (*SizeOfBuffer > 0) {
+ ASSERT (Buffer != NULL);
+ }
+
+ if ((*SizeOfBuffer > MaximumDatumSize) ||
+ (*SizeOfBuffer == MAX_ADDRESS)) {
+ *SizeOfBuffer = MaximumDatumSize;
+ return NULL;
+ }
+
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
+ *SizeOfPatchVariable = *SizeOfBuffer;
+
+ return (VOID *) Buffer;
+}
+
+/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified
+ by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
+ then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
+ to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return The status of the set operation.
+
+**/
+RETURN_STATUS
+EFIAPI
+LibPatchPcdSetPtrAndSizeS (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ )
+{
+ ASSERT (PatchVariable != NULL);
+ ASSERT (SizeOfPatchVariable != NULL);
+ ASSERT (SizeOfBuffer != NULL);
+
+ if (*SizeOfBuffer > 0) {
+ ASSERT (Buffer != NULL);
+ }
+
+ if ((*SizeOfBuffer > MaximumDatumSize) ||
+ (*SizeOfBuffer == MAX_ADDRESS)) {
+ *SizeOfBuffer = MaximumDatumSize;
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
+ *SizeOfPatchVariable = *SizeOfBuffer;
+
+ return RETURN_SUCCESS;
+}
+
+/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c
index 431ee7206a..79f769557b 100644
--- a/MdePkg/Library/DxePcdLib/DxePcdLib.c
+++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c
@@ -1362,7 +1362,7 @@ LibPcdGetNextTokenSpace (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -1374,7 +1374,7 @@ LibPcdGetNextTokenSpace (
VOID *
EFIAPI
LibPatchPcdSetPtr (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
@@ -1412,7 +1412,7 @@ LibPatchPcdSetPtr (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -1424,7 +1424,7 @@ LibPatchPcdSetPtr (
RETURN_STATUS
EFIAPI
LibPatchPcdSetPtrS (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
@@ -1448,6 +1448,117 @@ LibPatchPcdSetPtrS (
return RETURN_SUCCESS;
}
+
+/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified by Buffer
+ and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
+ MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
+ NULL to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and NULL must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return Return the pointer to the buffer been set.
+
+**/
+VOID *
+EFIAPI
+LibPatchPcdSetPtrAndSize (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ )
+{
+ ASSERT (PatchVariable != NULL);
+ ASSERT (SizeOfPatchVariable != NULL);
+ ASSERT (SizeOfBuffer != NULL);
+
+ if (*SizeOfBuffer > 0) {
+ ASSERT (Buffer != NULL);
+ }
+
+ if ((*SizeOfBuffer > MaximumDatumSize) ||
+ (*SizeOfBuffer == MAX_ADDRESS)) {
+ *SizeOfBuffer = MaximumDatumSize;
+ return NULL;
+ }
+
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
+ *SizeOfPatchVariable = *SizeOfBuffer;
+
+ return (VOID *) Buffer;
+}
+
+/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified
+ by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
+ then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
+ to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return The status of the set operation.
+
+**/
+RETURN_STATUS
+EFIAPI
+LibPatchPcdSetPtrAndSizeS (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ )
+{
+ ASSERT (PatchVariable != NULL);
+ ASSERT (SizeOfPatchVariable != NULL);
+ ASSERT (SizeOfBuffer != NULL);
+
+ if (*SizeOfBuffer > 0) {
+ ASSERT (Buffer != NULL);
+ }
+
+ if ((*SizeOfBuffer > MaximumDatumSize) ||
+ (*SizeOfBuffer == MAX_ADDRESS)) {
+ *SizeOfBuffer = MaximumDatumSize;
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
+ *SizeOfPatchVariable = *SizeOfBuffer;
+
+ return RETURN_SUCCESS;
+}
+
/**
Retrieve additional information associated with a PCD token.
diff --git a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
index 3d7139682a..53e8ad6c00 100644
--- a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
+++ b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
@@ -1363,7 +1363,7 @@ LibPcdGetNextTokenSpace (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -1375,7 +1375,7 @@ LibPcdGetNextTokenSpace (
VOID *
EFIAPI
LibPatchPcdSetPtr (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
@@ -1413,7 +1413,7 @@ LibPatchPcdSetPtr (
If SizeOfBuffer is NULL, then ASSERT().
If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
- @param[in] PatchVariable A pointer to the global variable in a module that is
+ @param[out] PatchVariable A pointer to the global variable in a module that is
the target of the set operation.
@param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
@param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
@@ -1425,7 +1425,7 @@ LibPatchPcdSetPtr (
RETURN_STATUS
EFIAPI
LibPatchPcdSetPtrS (
- IN VOID *PatchVariable,
+ OUT VOID *PatchVariable,
IN UINTN MaximumDatumSize,
IN OUT UINTN *SizeOfBuffer,
IN CONST VOID *Buffer
@@ -1449,6 +1449,117 @@ LibPatchPcdSetPtrS (
return RETURN_SUCCESS;
}
+
+/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified by Buffer
+ and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
+ MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
+ NULL to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and NULL must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return Return the pointer to the buffer been set.
+
+**/
+VOID *
+EFIAPI
+LibPatchPcdSetPtrAndSize (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ )
+{
+ ASSERT (PatchVariable != NULL);
+ ASSERT (SizeOfPatchVariable != NULL);
+ ASSERT (SizeOfBuffer != NULL);
+
+ if (*SizeOfBuffer > 0) {
+ ASSERT (Buffer != NULL);
+ }
+
+ if ((*SizeOfBuffer > MaximumDatumSize) ||
+ (*SizeOfBuffer == MAX_ADDRESS)) {
+ *SizeOfBuffer = MaximumDatumSize;
+ return NULL;
+ }
+
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
+ *SizeOfPatchVariable = *SizeOfBuffer;
+
+ return (VOID *) Buffer;
+}
+
+/**
+ Sets a value and size of a patchable PCD entry that is type pointer.
+
+ Sets the PCD entry specified by PatchVariable to the value specified
+ by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
+ then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
+ to indicate that the set operation was not actually performed.
+ If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
+ MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
+
+ If PatchVariable is NULL, then ASSERT().
+ If SizeOfPatchVariable is NULL, then ASSERT().
+ If SizeOfBuffer is NULL, then ASSERT().
+ If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
+
+ @param[out] PatchVariable A pointer to the global variable in a module that is
+ the target of the set operation.
+ @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
+ @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
+ @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
+ @param[in] Buffer A pointer to the buffer to used to set the target variable.
+
+ @return The status of the set operation.
+
+**/
+RETURN_STATUS
+EFIAPI
+LibPatchPcdSetPtrAndSizeS (
+ OUT VOID *PatchVariable,
+ OUT UINTN *SizeOfPatchVariable,
+ IN UINTN MaximumDatumSize,
+ IN OUT UINTN *SizeOfBuffer,
+ IN CONST VOID *Buffer
+ )
+{
+ ASSERT (PatchVariable != NULL);
+ ASSERT (SizeOfPatchVariable != NULL);
+ ASSERT (SizeOfBuffer != NULL);
+
+ if (*SizeOfBuffer > 0) {
+ ASSERT (Buffer != NULL);
+ }
+
+ if ((*SizeOfBuffer > MaximumDatumSize) ||
+ (*SizeOfBuffer == MAX_ADDRESS)) {
+ *SizeOfBuffer = MaximumDatumSize;
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
+ *SizeOfPatchVariable = *SizeOfBuffer;
+
+ return RETURN_SUCCESS;
+}
+
/**
Retrieve additional information associated with a PCD token.