]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Pei/Pcd.c
Code scrub for PCD PEIM.
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Pcd.c
index daaba4b539615654c82be19f0a959ed28e081eb2..28088afc5be14a397b6e3645e75be7aa425bab9e 100644 (file)
@@ -1,5 +1,7 @@
-/** @file PCD PEIM\r
-\r
+/** @file \r
+  PCD PEIM manage PCD database to manage all dynamic PCD in PEI phase. PCD PEIM\r
+  also produce PCD_PPI.\r
+  \r
 Copyright (c) 2006, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
@@ -9,14 +11,10 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-\r
-Module Name: Pcd.c\r
-\r
 **/\r
 \r
 #include "Service.h"\r
 \r
-\r
 PCD_PPI mPcdPpiInstance = {\r
   PeiPcdSetSku,\r
 \r
@@ -56,16 +54,23 @@ PCD_PPI mPcdPpiInstance = {
   PeiPcdGetNextTokenSpace\r
 };\r
 \r
-\r
-\r
 STATIC EFI_PEI_PPI_DESCRIPTOR  mPpiPCD = {\r
   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
   &gPcdPpiGuid,\r
   &mPcdPpiInstance\r
 };\r
 \r
+/**\r
+  Main entry for PCD PEIM driver.\r
+  \r
+  This routine initialize the PCD database for PEI phase and install PCD_PPI.\r
 \r
+  @param FfsHeader       Pointer to PEIM FFS header image\r
+  @param PeiServices     Pointer to EFI_PEI_SERVICES\r
 \r
+  @return Status of install PCD_PPI\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PcdPeimInit (\r
@@ -73,17 +78,34 @@ PcdPeimInit (
   IN EFI_PEI_SERVICES         **PeiServices\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
   BuildPcdDatabase ();\r
-  \r
-  Status = PeiServicesInstallPpi (&mPpiPCD);\r
 \r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  return EFI_SUCCESS;\r
+  return PeiServicesInstallPpi (&mPpiPCD);\r
 }\r
 \r
+/**\r
+  Sets the SKU value for subsequent calls to set or get PCD token values.\r
+\r
+  SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values. \r
+  SetSku() is normally called only once by the system.\r
+\r
+  For each item (token), the database can hold a single value that applies to all SKUs, \r
+  or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r
+  SKU-specific values are called SKU enabled. \r
+  \r
+  The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.  \r
+  For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r
+  single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r
+  last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r
+  the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been \r
+  set for that Id, the results are unpredictable.\r
+\r
+  @param[in]  SkuId The SKU value that will be used when the PCD service will retrieve and \r
+              set values associated with a PCD token.\r
+\r
+  @retval VOID\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 PeiPcdSetSku (\r
@@ -96,8 +118,17 @@ PeiPcdSetSku (
   return;\r
 }\r
 \r
+/**\r
+  Retrieves an 8-bit value for a given PCD token.\r
 \r
+  Retrieves the current byte-sized value for a PCD token number.  \r
+  If the TokenNumber is invalid, the results are unpredictable.\r
+  \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
+  @return The UINT8 value.\r
+  \r
+**/\r
 UINT8\r
 EFIAPI\r
 PeiPcdGet8 (\r
@@ -107,8 +138,17 @@ PeiPcdGet8 (
   return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r
 }\r
 \r
+/**\r
+  Retrieves an 16-bit value for a given PCD token.\r
 \r
+  Retrieves the current 16-bits value for a PCD token number.  \r
+  If the TokenNumber is invalid, the results are unpredictable.\r
+  \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
+  @return The UINT16 value.\r
+  \r
+**/\r
 UINT16\r
 EFIAPI\r
 PeiPcdGet16 (\r
@@ -118,8 +158,17 @@ PeiPcdGet16 (
   return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r
 }\r
 \r
+/**\r
+  Retrieves an 32-bit value for a given PCD token.\r
 \r
+  Retrieves the current 32-bits value for a PCD token number.  \r
+  If the TokenNumber is invalid, the results are unpredictable.\r
+  \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
+  @return The UINT32 value.\r
+  \r
+**/\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32 (\r
@@ -129,8 +178,17 @@ PeiPcdGet32 (
   return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r
 }\r
 \r
+/**\r
+  Retrieves an 64-bit value for a given PCD token.\r
 \r
+  Retrieves the current 64-bits value for a PCD token number.  \r
+  If the TokenNumber is invalid, the results are unpredictable.\r
+  \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
+  @return The UINT64 value.\r
+  \r
+**/\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64 (\r
@@ -140,8 +198,19 @@ PeiPcdGet64 (
   return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));\r
 }\r
 \r
+/**\r
+  Retrieves a pointer to a value for a given PCD token.\r
+\r
+  Retrieves the current pointer to the buffer for a PCD token number.  \r
+  Do not make any assumptions about the alignment of the pointer that \r
+  is returned by this function call.  If the TokenNumber is invalid, \r
+  the results are unpredictable.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
+  @return The pointer to the buffer to be retrived.\r
+  \r
+**/\r
 VOID *\r
 EFIAPI\r
 PeiPcdGetPtr (\r
@@ -151,8 +220,19 @@ PeiPcdGetPtr (
   return GetWorker (TokenNumber, 0);\r
 }\r
 \r
+/**\r
+  Retrieves a Boolean value for a given PCD token.\r
 \r
+  Retrieves the current boolean value for a PCD token number.  \r
+  Do not make any assumptions about the alignment of the pointer that \r
+  is returned by this function call.  If the TokenNumber is invalid, \r
+  the results are unpredictable.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+\r
+  @return The Boolean value.\r
+  \r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBool (\r
@@ -162,8 +242,17 @@ PeiPcdGetBool (
   return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r
 }\r
 \r
+/**\r
+  Retrieves the size of the value for a given PCD token.\r
+\r
+  Retrieves the current size of a particular PCD token.  \r
+  If the TokenNumber is invalid, the results are unpredictable.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
+  @return The size of the value for the PCD token.\r
+  \r
+**/\r
 UINTN\r
 EFIAPI\r
 PeiPcdGetSize (\r
@@ -209,8 +298,20 @@ PeiPcdGetSize (
 \r
 }\r
 \r
+/**\r
+  Retrieves an 8-bit value for a given PCD token.\r
 \r
+  Retrieves the 8-bit value of a particular PCD token.  \r
+  If the TokenNumber is invalid or the token space\r
+  specified by Guid does not exist, the results are \r
+  unpredictable.\r
 \r
+  @param[in]  Guid              The token space for the token number.\r
+  @param[in]  ExTokenNumber     The PCD token number. \r
+\r
+  @return The size 8-bit value for the PCD token.\r
+  \r
+**/\r
 UINT8\r
 EFIAPI\r
 PeiPcdGet8Ex (\r
@@ -221,8 +322,20 @@ PeiPcdGet8Ex (
   return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));\r
 }\r
 \r
+/**\r
+  Retrieves an 16-bit value for a given PCD token.\r
 \r
+  Retrieves the 16-bit value of a particular PCD token.  \r
+  If the TokenNumber is invalid or the token space\r
+  specified by Guid does not exist, the results are \r
+  unpredictable.\r
 \r
+  @param[in]  Guid          The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+\r
+  @return The size 16-bit value for the PCD token.\r
+  \r
+**/\r
 UINT16\r
 EFIAPI\r
 PeiPcdGet16Ex (\r
@@ -233,8 +346,20 @@ PeiPcdGet16Ex (
   return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));\r
 }\r
 \r
+/**\r
+  Retrieves an 32-bit value for a given PCD token.\r
+\r
+  Retrieves the 32-bit value of a particular PCD token.  \r
+  If the TokenNumber is invalid or the token space\r
+  specified by Guid does not exist, the results are \r
+  unpredictable.\r
 \r
+  @param[in]  Guid The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
+  @return The size 32-bit value for the PCD token.\r
+  \r
+**/\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32Ex (\r
@@ -245,8 +370,20 @@ PeiPcdGet32Ex (
   return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));\r
 }\r
 \r
+/**\r
+  Retrieves an 64-bit value for a given PCD token.\r
+\r
+  Retrieves the 64-bit value of a particular PCD token.  \r
+  If the TokenNumber is invalid or the token space\r
+  specified by Guid does not exist, the results are \r
+  unpredictable.\r
 \r
+  @param[in]  Guid The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
+  @return The size 64-bit value for the PCD token.\r
+  \r
+**/\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64Ex (\r
@@ -257,8 +394,20 @@ PeiPcdGet64Ex (
   return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));\r
 }\r
 \r
+/**\r
+  Retrieves a pointer to a value for a given PCD token.\r
 \r
+  Retrieves the current pointer to the buffer for a PCD token number.  \r
+  Do not make any assumptions about the alignment of the pointer that \r
+  is returned by this function call.  If the TokenNumber is invalid, \r
+  the results are unpredictable.\r
 \r
+  @param[in]  Guid          The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+\r
+  @return The pointer to the buffer to be retrived.\r
+  \r
+**/\r
 VOID *\r
 EFIAPI\r
 PeiPcdGetPtrEx (\r
@@ -269,8 +418,20 @@ PeiPcdGetPtrEx (
   return ExGetWorker (Guid, ExTokenNumber, 0);\r
 }\r
 \r
+/**\r
+  Retrieves an Boolean value for a given PCD token.\r
+\r
+  Retrieves the Boolean value of a particular PCD token.  \r
+  If the TokenNumber is invalid or the token space\r
+  specified by Guid does not exist, the results are \r
+  unpredictable.\r
 \r
+  @param[in]  Guid          The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
+  @return The size Boolean value for the PCD token.\r
+  \r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBoolEx (\r
@@ -281,8 +442,18 @@ PeiPcdGetBoolEx (
   return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));\r
 }\r
 \r
+/**\r
+  Retrieves the size of the value for a given PCD token.\r
+\r
+  Retrieves the current size of a particular PCD token.  \r
+  If the TokenNumber is invalid, the results are unpredictable.\r
 \r
+  @param[in]  Guid          The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
+  @return The size of the value for the PCD token.\r
+  \r
+**/\r
 UINTN\r
 EFIAPI\r
 PeiPcdGetSizeEx (\r
@@ -297,8 +468,23 @@ PeiPcdGetSizeEx (
   return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));\r
 }\r
 \r
+/**\r
+  Sets an 8-bit value for a given PCD token.\r
 \r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
+\r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet8 (\r
@@ -309,8 +495,23 @@ PeiPcdSet8 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 16-bit value for a given PCD token.\r
+\r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
 \r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet16 (\r
@@ -321,8 +522,23 @@ PeiPcdSet16 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 32-bit value for a given PCD token.\r
 \r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
+\r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet32 (\r
@@ -333,8 +549,23 @@ PeiPcdSet32 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 64-bit value for a given PCD token.\r
+\r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
 \r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet64 (\r
@@ -345,7 +576,27 @@ PeiPcdSet64 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
-\r
+/**\r
+  Sets a value of a specified size for a given PCD token.\r
+\r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
+\r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.  \r
+                              On input, if the SizeOfValue is greater than the maximum size supported \r
+                              for this TokenNumber then the output value of SizeOfValue will reflect \r
+                              the maximum size supported for this TokenNumber.\r
+  @param[in]  Buffer The buffer to set for the PCD token.\r
+\r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetPtr (\r
@@ -357,8 +608,23 @@ PeiPcdSetPtr (
   return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r
 }\r
 \r
+/**\r
+  Sets an Boolean value for a given PCD token.\r
 \r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
+\r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetBool (\r
@@ -369,8 +635,24 @@ PeiPcdSetBool (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 8-bit value for a given PCD token.\r
 \r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  Guid          The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+  @param[in]  Value         The value to set for the PCD token.\r
+\r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet8Ex (\r
@@ -382,8 +664,24 @@ PeiPcdSet8Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 16-bit value for a given PCD token.\r
+\r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
 \r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet16Ex (\r
@@ -395,8 +693,24 @@ PeiPcdSet16Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 32-bit value for a given PCD token.\r
+\r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  Guid          The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+  @param[in]  Value         The value to set for the PCD token.\r
 \r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet32Ex (\r
@@ -408,8 +722,24 @@ PeiPcdSet32Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 64-bit value for a given PCD token.\r
 \r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param[in]  Guid          The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+  @param[in]  Value         The value to set for the PCD token.\r
+\r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet64Ex (\r
@@ -421,22 +751,58 @@ PeiPcdSet64Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
-\r
-\r
+/**\r
+  Sets a value of a specified size for a given PCD token.\r
+\r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
+\r
+  @param[in]        Guid            The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]        ExTokenNumber   The PCD token number. \r
+  @param[in, out]   SizeOfBuffer    A pointer to the length of the value being set for the PCD token.  \r
+                                    On input, if the SizeOfValue is greater than the maximum size supported \r
+                                    for this TokenNumber then the output value of SizeOfValue will reflect \r
+                                    the maximum size supported for this TokenNumber.\r
+  @param[in]        Value           The buffer to set for the PCD token.\r
+\r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetPtrEx (\r
-  IN CONST EFI_GUID               *Guid,\r
-  IN UINTN                        ExTokenNumber,\r
-  IN UINTN                        *SizeOfBuffer,\r
-  IN VOID                         *Value\r
+  IN     CONST EFI_GUID               *Guid,\r
+  IN     UINTN                        ExTokenNumber,\r
+  IN OUT UINTN                        *SizeOfBuffer,\r
+  IN     VOID                         *Value\r
   )\r
 {\r
   return ExSetWorker (ExTokenNumber, Guid, Value, SizeOfBuffer, TRUE);\r
 }\r
 \r
+/**\r
+  Sets an Boolean value for a given PCD token.\r
+\r
+  When the PCD service sets a value, it will check to ensure that the \r
+  size of the value being set is compatible with the Token's existing definition.  \r
+  If it is not, an error will be returned.\r
 \r
+  @param [in]  Guid          The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param [in]  ExTokenNumber The PCD token number. \r
+  @param [in]  Value         The value to set for the PCD token.\r
 \r
+  @retval EFI_SUCCESS  Procedure returned successfully.\r
+  @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data \r
+                                  being set was incompatible with a call to this function.  \r
+                                  Use GetSize() to retrieve the size of the target data.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the requested token number.\r
+  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetBoolEx (\r
@@ -448,9 +814,18 @@ PeiPcdSetBoolEx (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Specifies a function to be called anytime the value of a designated token is changed.\r
 \r
+  @param[in]  Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+  @param[in]  CallBackFunction The function prototype called when the value associated with the CallBackToken is set.  \r
 \r
+  @retval EFI_SUCCESS  The PCD service has successfully established a call event \r
+                        for the CallBackToken requested.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiRegisterCallBackOnSet (\r
@@ -468,8 +843,18 @@ PeiRegisterCallBackOnSet (
   return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);\r
 }\r
 \r
+/**\r
+  Cancels a previously set callback function for a particular PCD token number.\r
 \r
+  @param[in]  Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
+  @param[in]  CallBackFunction The function prototype called when the value associated with the CallBackToken is set.  \r
 \r
+  @retval EFI_SUCCESS  The PCD service has successfully established a call event \r
+                        for the CallBackToken requested.\r
+  @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PcdUnRegisterCallBackOnSet (\r
@@ -487,8 +872,24 @@ PcdUnRegisterCallBackOnSet (
   return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);\r
 }\r
 \r
+/**\r
+  Retrieves the next valid PCD token for a given namespace.\r
 \r
+  @param[in]  Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in, out]  TokenNumber A pointer to the PCD token number to use to find the subsequent token number.  \r
+                  If the input token namespace or token number does not exist on the platform, \r
+                  an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token, \r
+                  have the pointer reference a TokenNumber value of 0. If the input token number is 0 and \r
+                  there is no valid token number for this token namespace,  *TokenNumber will be assigned to \r
+                  0 and the function return EFI_SUCCESS. If the token number is the last valid token number, \r
+                  *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.\r
 \r
+  @retval EFI_SUCCESS  The PCD service retrieved the next valid token number. Or the input token number \r
+                        is already the last valid token number in the PCD database. \r
+                        In the later case, *TokenNumber is updated with the value of 0.\r
+  @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdGetNextToken (\r
@@ -500,7 +901,7 @@ PeiPcdGetNextToken (
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   EFI_GUID            *MatchGuid;\r
   DYNAMICEX_MAPPING   *ExMapTable;\r
-  UINTN               i;\r
+  UINTN               Index;\r
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
 \r
@@ -547,8 +948,8 @@ PeiPcdGetNextToken (
     //\r
     // Locate the GUID in ExMapTable first.\r
     //\r
-    for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
-      if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {\r
+    for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+      if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
         Found = TRUE;\r
         break;\r
       }\r
@@ -556,22 +957,22 @@ PeiPcdGetNextToken (
 \r
     if (Found) {\r
       if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
-        *TokenNumber = ExMapTable[i].ExTokenNumber;\r
+        *TokenNumber = ExMapTable[Index].ExTokenNumber;\r
          return EFI_SUCCESS;\r
       }\r
 \r
-      for ( ; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
-        if (ExMapTable[i].ExTokenNumber == *TokenNumber) {\r
-          i++;\r
-          if (i == PEI_EXMAPPING_TABLE_SIZE) {\r
+      for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+        if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {\r
+          Index++;\r
+          if (Index == PEI_EXMAPPING_TABLE_SIZE) {\r
             //\r
             // Exceed the length of ExMap Table\r
             //\r
             *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
             return EFI_SUCCESS;\r
           }\r
-          if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {\r
-            *TokenNumber = ExMapTable[i].ExTokenNumber;\r
+          if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
+            *TokenNumber = ExMapTable[Index].ExTokenNumber;\r
             return EFI_SUCCESS;\r
           } else {\r
             *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
@@ -586,8 +987,27 @@ PeiPcdGetNextToken (
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Retrieves the next valid PCD token namespace for a given namespace.\r
+\r
+  @param[in, out]  Guid An indirect pointer to EFI_GUID.  On input it designates \r
+                    a known token namespace from which the search will start. On output, \r
+                    it designates the next valid token namespace on the platform. If the input \r
+                    token namespace does not exist on the platform, an error is returned and \r
+                    the value of *Guid is undefined. If *Guid is NULL, then the GUID of the \r
+                    first token space of the current platform is assigned to *Guid the function \r
+                    return EFI_SUCCESS. If  *Guid is NULL  and there is no namespace exist in \r
+                    the platform other than the default (NULL) tokennamespace, *Guid is unchanged \r
+                    and the function return EFI_SUCCESS. If this input token namespace is the last \r
+                    namespace on the platform, *Guid will be assigned to NULL and the function return \r
+                    EFI_SUCCESS. \r
+\r
+  @retval EFI_SUCCESS  The PCD service retrieved the next valid token space Guid. \r
+                        Or the input token space Guid is already the last valid token space Guid \r
+                        in the PCD database. In the later case, *Guid is updated with the value of NULL.\r
+  @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.\r
 \r
-\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdGetNextTokenSpace (\r
@@ -598,7 +1018,7 @@ PeiPcdGetNextTokenSpace (
   EFI_GUID            *MatchGuid;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   DYNAMICEX_MAPPING   *ExMapTable;\r
-  UINTN               i;\r
+  UINTN               Index;\r
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
 \r
@@ -644,18 +1064,18 @@ PeiPcdGetNextTokenSpace (
   GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r
 \r
   Found = FALSE;\r
-  for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
-    if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {\r
+  for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+    if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
       Found = TRUE;\r
       break;\r
     }\r
   }\r
 \r
   if (Found) {\r
-    i++;\r
-    for ( ; i < PEI_EXMAPPING_TABLE_SIZE; i++ ) {\r
-      if (ExMapTable[i].ExGuidIndex != GuidTableIdx ) {\r
-        *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[i].ExGuidIndex];\r
+    Index++;\r
+    for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++ ) {\r
+      if (ExMapTable[Index].ExGuidIndex != GuidTableIdx ) {\r
+        *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[Index].ExGuidIndex];\r
         return EFI_SUCCESS;\r
       }\r
     }\r
@@ -667,6 +1087,19 @@ PeiPcdGetNextTokenSpace (
 \r
 }\r
 \r
+/**\r
+  Get PCD value's size for POINTER type PCD.\r
+  \r
+  The POINTER type PCD's value will be stored into a buffer in specificed size.\r
+  The max size of this PCD's value is described in PCD's definition in DEC file.\r
+\r
+  @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
+  @param MaxSize                  Maxmium size of PCD's value\r
+  @param Database                 Pcd database in PEI phase.\r
+\r
+  @return PCD value's size for POINTER type PCD.\r
+\r
+**/\r
 UINTN\r
 GetPtrTypeSize (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
@@ -678,7 +1111,7 @@ GetPtrTypeSize (
   UINTN       LocalTokenNumber;\r
   SKU_ID      *SkuIdTable;\r
   SIZE_INFO   *SizeTable;\r
-  UINTN       i;\r
+  UINTN       Index;\r
 \r
   SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r
 \r
@@ -693,7 +1126,7 @@ GetPtrTypeSize (
   // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type \r
   // PCD entry.\r
   //\r
-  if (LocalTokenNumber & PCD_TYPE_VPD) {\r
+  if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
       //\r
       // We have only one entry for VPD enabled PCD entry:\r
       // 1) MAX Size.\r
@@ -715,9 +1148,9 @@ GetPtrTypeSize (
       // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r
-      for (i = 0; i < SkuIdTable[0]; i++) {\r
-        if (SkuIdTable[1 + i] == Database->Init.SystemSkuId) {\r
-          return SizeTable[SizeTableIdx + 1 + i];\r
+      for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
+        if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r
+          return SizeTable[SizeTableIdx + 1 + Index];\r
         }\r
       }\r
       return SizeTable[SizeTableIdx + 1];\r
@@ -725,8 +1158,20 @@ GetPtrTypeSize (
   }\r
 }\r
 \r
+/**\r
+  Set PCD value's size for POINTER type PCD.\r
+  \r
+  The POINTER type PCD's value will be stored into a buffer in specificed size.\r
+  The max size of this PCD's value is described in PCD's definition in DEC file.\r
+\r
+  @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
+  @param CurrentSize              Maxmium size of PCD's value\r
+  @param Database                 Pcd database in PEI phase.\r
 \r
+  @retval TRUE  Success to set PCD's value size, which is not exceed maxmium size\r
+  @retval FALSE Fail to set PCD's value size, which maybe exceed maxmium size\r
 \r
+**/\r
 BOOLEAN\r
 SetPtrTypeSize (\r
   IN          UINTN             LocalTokenNumberTableIdx,\r
@@ -738,7 +1183,7 @@ SetPtrTypeSize (
   UINTN       LocalTokenNumber;\r
   SKU_ID      *SkuIdTable;\r
   SIZE_INFO   *SizeTable;\r
-  UINTN       i;\r
+  UINTN       Index;\r
   UINTN       MaxSize;\r
   \r
   SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r
@@ -754,7 +1199,7 @@ SetPtrTypeSize (
   // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type \r
   // PCD entry.\r
   //\r
-  if (LocalTokenNumber & PCD_TYPE_VPD) {\r
+  if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
       //\r
       // We shouldn't come here as we don't support SET for VPD\r
       //\r
@@ -782,9 +1227,9 @@ SetPtrTypeSize (
       // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r
-      for (i = 0; i < SkuIdTable[0]; i++) {\r
-        if (SkuIdTable[1 + i] == Database->Init.SystemSkuId) {\r
-          SizeTable[SizeTableIdx + 1 + i] = (SIZE_INFO) *CurrentSize;\r
+      for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
+        if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r
+          SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;\r
           return TRUE;\r
         }\r
       }\r