]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxePcdLib/DxePcdLib.c
MdePkg PeiMemoryAllocationLib: Update InternalAllocateAlignedPages
[mirror_edk2.git] / MdePkg / Library / DxePcdLib / DxePcdLib.c
index 6f3a1b28613504d1a632e9318b302f8b5f106e43..371166818a34a5fea352bf58232bbf12e8a4af41 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation of PcdLib class library for DXE phase.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, 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
@@ -125,7 +125,6 @@ GetPcdInfoProtocolPointer (
   This function provides a means by which SKU support can be established in the PCD infrastructure.\r
 \r
   Sets the current SKU in the PCD database to the value specified by SkuId.  SkuId is returned.\r
-  If SkuId >= PCD_MAX_SKU_ID, then ASSERT(). \r
 \r
   @param  SkuId   The SKU value that will be used when the PCD service retrieves and sets values\r
                   associated with a PCD token.\r
@@ -139,8 +138,6 @@ LibPcdSetSku (
   IN UINTN   SkuId\r
   )\r
 {\r
-  ASSERT (SkuId < PCD_MAX_SKU_ID);\r
-\r
   GetPcdProtocol()->SetSku (SkuId);\r
 \r
   return SkuId;\r
@@ -484,14 +481,13 @@ LibPcdGetExSize (
 \r
 \r
 \r
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
 /**\r
   This function provides a means by which to set a value for a given PCD token.\r
   \r
   Sets the 8-bit value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
 \r
-  If the set operation was not correctly performed, then ASSERT().\r
-\r
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
   @param[in]  Value         The 8-bit value to set.\r
 \r
@@ -505,10 +501,7 @@ LibPcdSet8 (
   IN UINT8             Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = GetPcdProtocol()->Set8 (TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPcdProtocol()->Set8 (TokenNumber, Value);\r
   \r
   return Value;\r
 }\r
@@ -521,8 +514,6 @@ LibPcdSet8 (
   Sets the 16-bit value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
 \r
-  If the set operation was not correctly performed, then ASSERT().\r
-\r
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
   @param[in]  Value         The 16-bit value to set.\r
 \r
@@ -536,10 +527,7 @@ LibPcdSet16 (
   IN UINT16            Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = GetPcdProtocol()->Set16 (TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPcdProtocol()->Set16 (TokenNumber, Value);\r
   \r
   return Value;\r
 }\r
@@ -552,8 +540,6 @@ LibPcdSet16 (
   Sets the 32-bit value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
 \r
-  If the set operation was not correctly performed, then ASSERT().\r
-\r
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
   @param[in]  Value         The 32-bit value to set.\r
 \r
@@ -567,10 +553,7 @@ LibPcdSet32 (
   IN UINT32            Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-  \r
-  Status = GetPcdProtocol()->Set32 (TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPcdProtocol()->Set32 (TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
@@ -582,8 +565,6 @@ LibPcdSet32 (
   \r
   Sets the 64-bit value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
-\r
-  If the set operation was not correctly performed, then ASSERT().\r
   \r
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
   @param[in]  Value         The 64-bit value to set.\r
@@ -598,10 +579,7 @@ LibPcdSet64 (
   IN UINT64            Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = GetPcdProtocol()->Set64 (TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPcdProtocol()->Set64 (TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
@@ -615,8 +593,7 @@ LibPcdSet64 (
   specified by Buffer and SizeOfBuffer.  Buffer is returned.  \r
   If SizeOfBuffer is greater than the maximum size support by TokenNumber, \r
   then set SizeOfBuffer to the maximum size supported by TokenNumber and \r
-  return NULL to indicate that the set operation was not actually performed,\r
-  or ASSERT() if the set operation was not correctly performed.\r
+  return NULL to indicate that the set operation was not actually performed.\r
 \r
   If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the \r
   maximum size supported by TokenName and NULL must be returned.\r
@@ -653,7 +630,6 @@ LibPcdSetPtr (
   if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
     return NULL;\r
   }\r
-  ASSERT_EFI_ERROR (Status);\r
 \r
   return (VOID *)Buffer;\r
 }\r
@@ -666,8 +642,6 @@ LibPcdSetPtr (
   Sets the Boolean value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
 \r
-  If the set operation was not correctly performed, then ASSERT().\r
-\r
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
   @param[in]  Value         The boolean value to set.\r
 \r
@@ -681,10 +655,7 @@ LibPcdSetBool (
   IN BOOLEAN           Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = GetPcdProtocol()->SetBool (TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPcdProtocol()->SetBool (TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
@@ -698,7 +669,6 @@ LibPcdSetBool (
   Guid to the value specified by Value. Value is returned.\r
 \r
   If Guid is NULL, then ASSERT().\r
-  If the set operation was not correctly performed, then ASSERT().\r
 \r
   @param[in]  Guid          The pointer to a 128-bit unique value that \r
                             designates which namespace to set a value from.\r
@@ -716,12 +686,9 @@ LibPcdSetEx8 (
   IN UINT8             Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
   ASSERT (Guid != NULL);\r
 \r
-  Status = GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
@@ -735,7 +702,6 @@ LibPcdSetEx8 (
   Guid to the value specified by Value. Value is returned.\r
 \r
   If Guid is NULL, then ASSERT().\r
-  If the set operation was not correctly performed, then ASSERT().\r
 \r
   @param[in]  Guid          The pointer to a 128-bit unique value that \r
                             designates which namespace to set a value from.\r
@@ -753,12 +719,9 @@ LibPcdSetEx16 (
   IN UINT16            Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
   ASSERT (Guid != NULL);\r
 \r
-  Status = GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
@@ -772,7 +735,6 @@ LibPcdSetEx16 (
   Guid to the value specified by Value. Value is returned.\r
 \r
   If Guid is NULL, then ASSERT().\r
-  If the set operation was not correctly performed, then ASSERT().\r
 \r
   @param[in]  Guid          The pointer to a 128-bit unique value that \r
                             designates which namespace to set a value from.\r
@@ -790,12 +752,9 @@ LibPcdSetEx32 (
   IN UINT32            Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
   ASSERT (Guid != NULL);\r
 \r
-  Status = GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
@@ -809,7 +768,6 @@ LibPcdSetEx32 (
   Guid to the value specified by Value. Value is returned.\r
 \r
   If Guid is NULL, then ASSERT().\r
-  If the set operation was not correctly performed, then ASSERT().\r
 \r
   @param[in]  Guid          The pointer to a 128-bit unique value that \r
                             designates which namespace to set a value from.\r
@@ -827,12 +785,9 @@ LibPcdSetEx64 (
   IN UINT64            Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
   ASSERT (Guid != NULL);\r
 \r
-  Status = GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
@@ -846,7 +801,7 @@ LibPcdSetEx64 (
   Buffer and SizeOfBuffer.  Buffer is returned.  If SizeOfBuffer is greater than \r
   the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size \r
   supported by TokenNumber and return NULL to indicate that the set operation \r
-  was not actually performed, or ASSERT() if the set operation was not corretly performed.\r
+  was not actually performed.\r
   \r
   If Guid is NULL, then ASSERT().\r
   If SizeOfBuffer is NULL, then ASSERT().\r
@@ -886,7 +841,6 @@ LibPcdSetExPtr (
   if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
     return NULL;\r
   }\r
-  ASSERT_EFI_ERROR (Status);\r
 \r
   return Buffer;\r
 }\r
@@ -900,7 +854,6 @@ LibPcdSetExPtr (
   Guid to the value specified by Value. Value is returned.\r
 \r
   If Guid is NULL, then ASSERT().\r
-  If the set operation was not correctly performed, then ASSERT().\r
 \r
   @param[in]  Guid          The pointer to a 128-bit unique value that \r
                             designates which namespace to set a value from.\r
@@ -918,17 +871,349 @@ LibPcdSetExBool (
   IN BOOLEAN           Value\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
   ASSERT (Guid != NULL);\r
 \r
-  Status = GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);\r
 \r
   return Value;\r
 }\r
+#endif\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 8-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 8-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSet8S (\r
+  IN UINTN          TokenNumber,\r
+  IN UINT8          Value\r
+  )\r
+{\r
+  return GetPcdProtocol()->Set8 (TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 16-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 16-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSet16S (\r
+  IN UINTN          TokenNumber,\r
+  IN UINT16         Value\r
+  )\r
+{\r
+  return GetPcdProtocol()->Set16 (TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 32-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 32-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSet32S (\r
+  IN UINTN          TokenNumber,\r
+  IN UINT32         Value\r
+  )\r
+{\r
+  return GetPcdProtocol()->Set32 (TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 64-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 64-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSet64S (\r
+  IN UINTN          TokenNumber,\r
+  IN UINT64         Value\r
+  )\r
+{\r
+  return GetPcdProtocol()->Set64 (TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets a buffer for the token specified by TokenNumber to the value specified\r
+  by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
+  support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
+  TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
+  was not actually performed.\r
+\r
+  If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the\r
+  maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.\r
+\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[in]      TokenNumber   The PCD token number to set a current value for.\r
+  @param[in, out] SizeOfBuffer  The size, in bytes, of Buffer.\r
+  @param[in]      Buffer        A pointer to the buffer to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetPtrS (\r
+  IN       UINTN    TokenNumber,\r
+  IN OUT   UINTN    *SizeOfBuffer,\r
+  IN CONST VOID     *Buffer\r
+  )\r
+{\r
+  ASSERT (SizeOfBuffer != NULL);\r
+\r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  return GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the boolean value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The boolean value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetBoolS (\r
+  IN UINTN          TokenNumber,\r
+  IN BOOLEAN        Value\r
+  )\r
+{\r
+  return GetPcdProtocol()->SetBool (TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 8-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param[in] Guid           The pointer to a 128-bit unique value that\r
+                            designates which namespace to set a value from.\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 8-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetEx8S (\r
+  IN CONST GUID     *Guid,\r
+  IN UINTN          TokenNumber,\r
+  IN UINT8          Value\r
+  )\r
+{\r
+  ASSERT (Guid != NULL);\r
+\r
+  return GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 16-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param[in] Guid           The pointer to a 128-bit unique value that\r
+                            designates which namespace to set a value from.\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 16-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetEx16S (\r
+  IN CONST GUID     *Guid,\r
+  IN UINTN          TokenNumber,\r
+  IN UINT16         Value\r
+  )\r
+{\r
+  ASSERT (Guid != NULL);\r
+\r
+  return GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 32-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param[in] Guid           The pointer to a 128-bit unique value that\r
+                            designates which namespace to set a value from.\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 32-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetEx32S (\r
+  IN CONST GUID     *Guid,\r
+  IN UINTN          TokenNumber,\r
+  IN UINT32         Value\r
+  )\r
+{\r
+  ASSERT (Guid != NULL);\r
+\r
+  return GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the 64-bit value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param[in] Guid           The pointer to a 128-bit unique value that\r
+                            designates which namespace to set a value from.\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The 64-bit value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetEx64S (\r
+  IN CONST GUID     *Guid,\r
+  IN UINTN          TokenNumber,\r
+  IN UINT64         Value\r
+  )\r
+{\r
+  ASSERT (Guid != NULL);\r
+\r
+  return GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets a buffer for the token specified by TokenNumber to the value specified by\r
+  Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size\r
+  support by TokenNumber, then set SizeOfBuffer to the maximum size supported by\r
+  TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation\r
+  was not actually performed.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+  If SizeOfBuffer is NULL, then ASSERT().\r
+  If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param[in]      Guid          Pointer to a 128-bit unique value that\r
+                                designates which namespace to set a value from.\r
+  @param[in]      TokenNumber   The PCD token number to set a current value for.\r
+  @param[in, out] SizeOfBuffer  The size, in bytes, of Buffer.\r
+  @param[in]      Buffer        A pointer to the buffer to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetExPtrS (\r
+  IN CONST GUID     *Guid,\r
+  IN       UINTN    TokenNumber,\r
+  IN OUT   UINTN    *SizeOfBuffer,\r
+  IN       VOID     *Buffer\r
+  )\r
+{\r
+  ASSERT (Guid != NULL);\r
+\r
+  ASSERT (SizeOfBuffer != NULL);\r
+\r
+  if (*SizeOfBuffer > 0) {\r
+    ASSERT (Buffer != NULL);\r
+  }\r
+\r
+  return GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
+}\r
+\r
+/**\r
+  This function provides a means by which to set a value for a given PCD token.\r
+\r
+  Sets the boolean value for the token specified by TokenNumber\r
+  to the value specified by Value.\r
 \r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param[in] Guid           The pointer to a 128-bit unique value that\r
+                            designates which namespace to set a value from.\r
+  @param[in] TokenNumber    The PCD token number to set a current value for.\r
+  @param[in] Value          The boolean value to set.\r
+\r
+  @return The status of the set operation.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LibPcdSetExBoolS (\r
+  IN CONST GUID     *Guid,\r
+  IN UINTN          TokenNumber,\r
+  IN BOOLEAN        Value\r
+  )\r
+{\r
+  ASSERT (Guid != NULL);\r
 \r
+  return GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);\r
+}\r
 \r
 /**\r
   Set up a notification function that is called when a specified token is set.\r
@@ -1074,7 +1359,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
@@ -1086,13 +1371,118 @@ 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
+  )\r
+{\r
+  ASSERT (PatchVariable != 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
+  \r
+  return (VOID *) Buffer;\r
+}\r
+\r
+/**\r
+  Sets a value 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 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[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
+LibPatchPcdSetPtrS (\r
+  OUT       VOID     *PatchVariable,\r
+  IN       UINTN    MaximumDatumSize,\r
+  IN OUT   UINTN    *SizeOfBuffer,\r
+  IN CONST VOID     *Buffer\r
+  )\r
+{\r
+  ASSERT (PatchVariable != 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
+\r
+  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
@@ -1106,10 +1496,66 @@ LibPatchPcdSetPtr (
   }\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
@@ -1165,8 +1611,6 @@ LibPcdGetInfoEx (
 /**\r
   Retrieve the currently set SKU Id.\r
 \r
-  If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().\r
-\r
   @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
             default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
             Id is returned.\r
@@ -1177,11 +1621,6 @@ LibPcdGetSku (
   VOID\r
   )\r
 {\r
-  UINTN SkuId;\r
-\r
-  SkuId = GetPiPcdInfoProtocolPointer()->GetSku ();\r
-  ASSERT (SkuId < PCD_MAX_SKU_ID);\r
-\r
-  return SkuId;\r
+  return GetPiPcdInfoProtocolPointer()->GetSku ();\r
 }\r
 \r