]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiPcdLib/PeiPcdLib.c
MdePkg PcdLib: Except for SizeOfBuffer is greater than the maximum size supported...
[mirror_edk2.git] / MdePkg / Library / PeiPcdLib / PeiPcdLib.c
index 31ff457fc8f7823cfc3b4d103298b3b9054f7ed4..536e1d05d9e9c42bbcd9285abbaf1ebefdfd9859 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation of PcdLib class library for PEI phase.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, 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
@@ -490,7 +490,9 @@ LibPcdGetExSize (
   \r
   Sets the 8-bit value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
-  \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
@@ -520,7 +522,9 @@ LibPcdSet8 (
   \r
   Sets the 16-bit value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
-  \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
@@ -550,7 +554,9 @@ LibPcdSet16 (
   \r
   Sets the 32-bit value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
-  \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
@@ -580,7 +586,9 @@ 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
+\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
 \r
@@ -612,7 +620,8 @@ 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
+  return NULL to indicate that the set operation was not actually performed,\r
+  or ASSERT() if the set operation was not corretly 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
@@ -636,18 +645,20 @@ LibPcdSetPtr (
   )\r
 {\r
   EFI_STATUS Status;\r
+  UINTN      InputSizeOfBuffer;\r
 \r
   ASSERT (SizeOfBuffer != NULL);\r
 \r
   if (*SizeOfBuffer > 0) {\r
     ASSERT (Buffer != NULL);\r
   }\r
-  \r
-  Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
 \r
-  if (EFI_ERROR (Status)) {\r
+  InputSizeOfBuffer = *SizeOfBuffer;\r
+  Status = (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
+  if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
     return NULL;\r
   }\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   return (VOID *) Buffer;\r
 }\r
@@ -659,7 +670,9 @@ LibPcdSetPtr (
   \r
   Sets the Boolean value for the token specified by TokenNumber \r
   to the value specified by Value.  Value is returned.\r
-  \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
@@ -689,9 +702,10 @@ LibPcdSetBool (
   \r
   Sets the 8-bit value for the token specified by TokenNumber and \r
   Guid to the value specified by Value. Value is returned.\r
-  \r
+\r
   If Guid is NULL, then ASSERT().\r
-  \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
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
@@ -726,9 +740,10 @@ LibPcdSetEx8 (
   \r
   Sets the 16-bit value for the token specified by TokenNumber and \r
   Guid to the value specified by Value. Value is returned.\r
-  \r
+\r
   If Guid is NULL, then ASSERT().\r
-  \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
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
@@ -761,9 +776,10 @@ LibPcdSetEx16 (
   \r
   Sets the 32-bit value for the token specified by TokenNumber and \r
   Guid to the value specified by Value. Value is returned.\r
-  \r
+\r
   If Guid is NULL, then ASSERT().\r
-  \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
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
@@ -798,8 +814,10 @@ LibPcdSetEx32 (
   \r
   Sets the 64-bit value for the token specified by TokenNumber and \r
   Guid to the value specified by Value. Value is returned.\r
+\r
   If Guid is NULL, then ASSERT().\r
-  \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
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r
@@ -835,7 +853,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\r
+  was not actually performed, or ASSERT() if the set operation was not corretly performed.\r
   \r
   If Guid is NULL, then ASSERT().\r
   If SizeOfBuffer is NULL, then ASSERT().\r
@@ -860,17 +878,21 @@ LibPcdSetExPtr (
   )\r
 {\r
   EFI_STATUS      Status;\r
+  UINTN           InputSizeOfBuffer;\r
+\r
+\r
   ASSERT (SizeOfBuffer != NULL);\r
   if (*SizeOfBuffer > 0) {\r
     ASSERT (Buffer != NULL);\r
   }\r
   ASSERT (Guid != NULL);\r
 \r
+  InputSizeOfBuffer = *SizeOfBuffer;\r
   Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
     return NULL;\r
   }\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   return Buffer;\r
 }\r
@@ -882,9 +904,10 @@ LibPcdSetExPtr (
   \r
   Sets the Boolean value for the token specified by TokenNumber and \r
   Guid to the value specified by Value. Value is returned.\r
-  \r
+\r
   If Guid is NULL, then ASSERT().\r
-  \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
   @param[in]  TokenNumber   The PCD token number to set a current value for.\r