]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxePcdLib/DxePcdLib.c
MdePkg PcdLib: Except for SizeOfBuffer is greater than the maximum size supported...
[mirror_edk2.git] / MdePkg / Library / DxePcdLib / DxePcdLib.c
index f14a74652978bb38f6c1af867ab4294c7faa6e77..6f3a1b28613504d1a632e9318b302f8b5f106e43 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation of PcdLib class library for DXE 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
@@ -489,7 +489,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
@@ -518,7 +520,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
@@ -547,7 +551,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
@@ -576,6 +582,8 @@ 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
@@ -607,7 +615,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 correctly 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
@@ -631,6 +640,7 @@ LibPcdSetPtr (
   )\r
 {\r
   EFI_STATUS Status;\r
+  UINTN      InputSizeOfBuffer;\r
 \r
   ASSERT (SizeOfBuffer != NULL);\r
 \r
@@ -638,10 +648,12 @@ LibPcdSetPtr (
     ASSERT (Buffer != NULL);\r
   }\r
 \r
+  InputSizeOfBuffer = *SizeOfBuffer;\r
   Status = GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer);\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) && (*SizeOfBuffer < InputSizeOfBuffer)) {\r
     return NULL;\r
   }\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   return (VOID *)Buffer;\r
 }\r
@@ -653,7 +665,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
@@ -682,9 +696,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
@@ -718,9 +733,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
@@ -754,9 +770,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
@@ -790,8 +807,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
@@ -827,7 +846,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
@@ -852,6 +871,7 @@ LibPcdSetExPtr (
   )\r
 {\r
   EFI_STATUS  Status;\r
+  UINTN       InputSizeOfBuffer;\r
 \r
   ASSERT (Guid != NULL);\r
 \r
@@ -861,10 +881,12 @@ LibPcdSetExPtr (
     ASSERT (Buffer != NULL);\r
   }\r
 \r
+  InputSizeOfBuffer = *SizeOfBuffer;\r
   Status = GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);\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
@@ -876,9 +898,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