]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code scrub for PCD PEIM.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 14 Jul 2008 07:17:04 +0000 (07:17 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 14 Jul 2008 07:17:04 +0000 (07:17 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5461 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/PCD/Pei/Pcd.c
MdeModulePkg/Universal/PCD/Pei/Service.c
MdeModulePkg/Universal/PCD/Pei/Service.h

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
 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
 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
 \r
 #include "Service.h"\r
 \r
-\r
 PCD_PPI mPcdPpiInstance = {\r
   PeiPcdSetSku,\r
 \r
 PCD_PPI mPcdPpiInstance = {\r
   PeiPcdSetSku,\r
 \r
@@ -56,16 +54,23 @@ PCD_PPI mPcdPpiInstance = {
   PeiPcdGetNextTokenSpace\r
 };\r
 \r
   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
 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
 \r
+  @param FfsHeader       Pointer to PEIM FFS header image\r
+  @param PeiServices     Pointer to EFI_PEI_SERVICES\r
 \r
 \r
+  @return Status of install PCD_PPI\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PcdPeimInit (\r
 EFI_STATUS\r
 EFIAPI\r
 PcdPeimInit (\r
@@ -73,17 +78,34 @@ PcdPeimInit (
   IN EFI_PEI_SERVICES         **PeiServices\r
   )\r
 {\r
   IN EFI_PEI_SERVICES         **PeiServices\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
   BuildPcdDatabase ();\r
   BuildPcdDatabase ();\r
-  \r
-  Status = PeiServicesInstallPpi (&mPpiPCD);\r
 \r
 \r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  return EFI_SUCCESS;\r
+  return PeiServicesInstallPpi (&mPpiPCD);\r
 }\r
 \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
 VOID\r
 EFIAPI\r
 PeiPcdSetSku (\r
@@ -96,8 +118,17 @@ PeiPcdSetSku (
   return;\r
 }\r
 \r
   return;\r
 }\r
 \r
+/**\r
+  Retrieves an 8-bit value for a given PCD token.\r
 \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
 \r
+  @return The UINT8 value.\r
+  \r
+**/\r
 UINT8\r
 EFIAPI\r
 PeiPcdGet8 (\r
 UINT8\r
 EFIAPI\r
 PeiPcdGet8 (\r
@@ -107,8 +138,17 @@ PeiPcdGet8 (
   return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r
 }\r
 \r
   return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r
 }\r
 \r
+/**\r
+  Retrieves an 16-bit value for a given PCD token.\r
 \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
 \r
+  @return The UINT16 value.\r
+  \r
+**/\r
 UINT16\r
 EFIAPI\r
 PeiPcdGet16 (\r
 UINT16\r
 EFIAPI\r
 PeiPcdGet16 (\r
@@ -118,8 +158,17 @@ PeiPcdGet16 (
   return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r
 }\r
 \r
   return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r
 }\r
 \r
+/**\r
+  Retrieves an 32-bit value for a given PCD token.\r
 \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
 \r
+  @return The UINT32 value.\r
+  \r
+**/\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32 (\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32 (\r
@@ -129,8 +178,17 @@ PeiPcdGet32 (
   return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r
 }\r
 \r
   return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r
 }\r
 \r
+/**\r
+  Retrieves an 64-bit value for a given PCD token.\r
 \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
 \r
+  @return The UINT64 value.\r
+  \r
+**/\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64 (\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64 (\r
@@ -140,8 +198,19 @@ PeiPcdGet64 (
   return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));\r
 }\r
 \r
   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
 \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
 \r
+  @return The pointer to the buffer to be retrived.\r
+  \r
+**/\r
 VOID *\r
 EFIAPI\r
 PeiPcdGetPtr (\r
 VOID *\r
 EFIAPI\r
 PeiPcdGetPtr (\r
@@ -151,8 +220,19 @@ PeiPcdGetPtr (
   return GetWorker (TokenNumber, 0);\r
 }\r
 \r
   return GetWorker (TokenNumber, 0);\r
 }\r
 \r
+/**\r
+  Retrieves a Boolean value for a given PCD token.\r
 \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
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+\r
+  @return The Boolean value.\r
+  \r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBool (\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBool (\r
@@ -162,8 +242,17 @@ PeiPcdGetBool (
   return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r
 }\r
 \r
   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
 \r
+  @param[in]  TokenNumber The PCD token number. \r
 \r
 \r
+  @return The size of the value for the PCD token.\r
+  \r
+**/\r
 UINTN\r
 EFIAPI\r
 PeiPcdGetSize (\r
 UINTN\r
 EFIAPI\r
 PeiPcdGetSize (\r
@@ -209,8 +298,20 @@ PeiPcdGetSize (
 \r
 }\r
 \r
 \r
 }\r
 \r
+/**\r
+  Retrieves an 8-bit value for a given PCD token.\r
 \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
 \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
 UINT8\r
 EFIAPI\r
 PeiPcdGet8Ex (\r
@@ -221,8 +322,20 @@ PeiPcdGet8Ex (
   return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));\r
 }\r
 \r
   return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));\r
 }\r
 \r
+/**\r
+  Retrieves an 16-bit value for a given PCD token.\r
 \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
 \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
 UINT16\r
 EFIAPI\r
 PeiPcdGet16Ex (\r
@@ -233,8 +346,20 @@ PeiPcdGet16Ex (
   return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));\r
 }\r
 \r
   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
 \r
+  @param[in]  Guid The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
 \r
+  @return The size 32-bit value for the PCD token.\r
+  \r
+**/\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32Ex (\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32Ex (\r
@@ -245,8 +370,20 @@ PeiPcdGet32Ex (
   return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));\r
 }\r
 \r
   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
 \r
+  @param[in]  Guid The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
 \r
+  @return The size 64-bit value for the PCD token.\r
+  \r
+**/\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64Ex (\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64Ex (\r
@@ -257,8 +394,20 @@ PeiPcdGet64Ex (
   return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));\r
 }\r
 \r
   return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));\r
 }\r
 \r
+/**\r
+  Retrieves a pointer to a value for a given PCD token.\r
 \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
 \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
 VOID *\r
 EFIAPI\r
 PeiPcdGetPtrEx (\r
@@ -269,8 +418,20 @@ PeiPcdGetPtrEx (
   return ExGetWorker (Guid, ExTokenNumber, 0);\r
 }\r
 \r
   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
 \r
+  @param[in]  Guid          The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
 \r
+  @return The size Boolean value for the PCD token.\r
+  \r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBoolEx (\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBoolEx (\r
@@ -281,8 +442,18 @@ PeiPcdGetBoolEx (
   return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));\r
 }\r
 \r
   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
 \r
+  @param[in]  Guid          The token space for the token number.\r
+  @param[in]  ExTokenNumber The PCD token number. \r
 \r
 \r
+  @return The size of the value for the PCD token.\r
+  \r
+**/\r
 UINTN\r
 EFIAPI\r
 PeiPcdGetSizeEx (\r
 UINTN\r
 EFIAPI\r
 PeiPcdGetSizeEx (\r
@@ -297,8 +468,23 @@ PeiPcdGetSizeEx (
   return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));\r
 }\r
 \r
   return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));\r
 }\r
 \r
+/**\r
+  Sets an 8-bit value for a given PCD token.\r
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet8 (\r
@@ -309,8 +495,23 @@ PeiPcdSet8 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
   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
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet16 (\r
@@ -321,8 +522,23 @@ PeiPcdSet16 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 32-bit value for a given PCD token.\r
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet32 (\r
@@ -333,8 +549,23 @@ PeiPcdSet32 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
   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
 \r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet64 (\r
@@ -345,7 +576,27 @@ PeiPcdSet64 (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
   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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetPtr (\r
@@ -357,8 +608,23 @@ PeiPcdSetPtr (
   return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r
 }\r
 \r
   return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r
 }\r
 \r
+/**\r
+  Sets an Boolean value for a given PCD token.\r
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetBool (\r
@@ -369,8 +635,24 @@ PeiPcdSetBool (
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
   return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 8-bit value for a given PCD token.\r
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet8Ex (\r
@@ -382,8 +664,24 @@ PeiPcdSet8Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
   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
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet16Ex (\r
@@ -395,8 +693,24 @@ PeiPcdSet16Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
   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
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet32Ex (\r
@@ -408,8 +722,24 @@ PeiPcdSet32Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
+/**\r
+  Sets an 64-bit value for a given PCD token.\r
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet64Ex (\r
@@ -421,22 +751,58 @@ PeiPcdSet64Ex (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
   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
 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
 {\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
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetBoolEx (\r
@@ -448,9 +814,18 @@ PeiPcdSetBoolEx (
   return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
 }\r
 \r
   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
 \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
 \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
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiRegisterCallBackOnSet (\r
 EFI_STATUS\r
 EFIAPI\r
 PeiRegisterCallBackOnSet (\r
@@ -468,8 +843,18 @@ PeiRegisterCallBackOnSet (
   return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);\r
 }\r
 \r
   return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);\r
 }\r
 \r
+/**\r
+  Cancels a previously set callback function for a particular PCD token number.\r
 \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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PcdUnRegisterCallBackOnSet (\r
@@ -487,8 +872,24 @@ PcdUnRegisterCallBackOnSet (
   return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);\r
 }\r
 \r
   return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);\r
 }\r
 \r
+/**\r
+  Retrieves the next valid PCD token for a given namespace.\r
 \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
 \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
 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
   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
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
 \r
@@ -547,8 +948,8 @@ PeiPcdGetNextToken (
     //\r
     // Locate the GUID in ExMapTable first.\r
     //\r
     //\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
         Found = TRUE;\r
         break;\r
       }\r
@@ -556,22 +957,22 @@ PeiPcdGetNextToken (
 \r
     if (Found) {\r
       if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
 \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
          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
             //\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
             return EFI_SUCCESS;\r
           } else {\r
             *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
@@ -586,8 +987,27 @@ PeiPcdGetNextToken (
   return EFI_NOT_FOUND;\r
 }\r
 \r
   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
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdGetNextTokenSpace (\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
   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
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
 \r
@@ -644,18 +1064,18 @@ PeiPcdGetNextTokenSpace (
   GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r
 \r
   Found = FALSE;\r
   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
       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
         return EFI_SUCCESS;\r
       }\r
     }\r
@@ -667,6 +1087,19 @@ PeiPcdGetNextTokenSpace (
 \r
 }\r
 \r
 \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
 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       LocalTokenNumber;\r
   SKU_ID      *SkuIdTable;\r
   SIZE_INFO   *SizeTable;\r
-  UINTN       i;\r
+  UINTN       Index;\r
 \r
   SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r
 \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
   // 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
       //\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
       // 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
         }\r
       }\r
       return SizeTable[SizeTableIdx + 1];\r
@@ -725,8 +1158,20 @@ GetPtrTypeSize (
   }\r
 }\r
 \r
   }\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
 \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
+**/\r
 BOOLEAN\r
 SetPtrTypeSize (\r
   IN          UINTN             LocalTokenNumberTableIdx,\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       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
   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
   // 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
       //\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
       // 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
           return TRUE;\r
         }\r
       }\r
index 16a5cc848928c48f91a51fbcbf39e6b5f205416d..fddab6be580f71768065fac5cb053c261cd79895 100644 (file)
@@ -21,7 +21,7 @@ Module Name: Service.c
   The function registers the CallBackOnSet fucntion\r
   according to TokenNumber and EFI_GUID space.\r
 \r
   The function registers the CallBackOnSet fucntion\r
   according to TokenNumber and EFI_GUID space.\r
 \r
-  @param  TokenNumber       The token number.\r
+  @param  ExTokenNumber       The token number.\r
   @param  Guid              The GUID space.\r
   @param  CallBackFunction  The Callback function to be registered.\r
   @param  Register          To register or unregister the callback function.\r
   @param  Guid              The GUID space.\r
   @param  CallBackFunction  The Callback function to be registered.\r
   @param  Register          To register or unregister the callback function.\r
@@ -30,7 +30,7 @@ Module Name: Service.c
   @retval EFI_NOT_FOUND If the PCD Entry is not found according to Token Number and GUID space.\r
   @retval EFI_OUT_OF_RESOURCES If the callback function can't be registered because there is not free\r
                                 slot left in the CallbackFnTable.\r
   @retval EFI_NOT_FOUND If the PCD Entry is not found according to Token Number and GUID space.\r
   @retval EFI_OUT_OF_RESOURCES If the callback function can't be registered because there is not free\r
                                 slot left in the CallbackFnTable.\r
---*/\r
+**/\r
 EFI_STATUS\r
 PeiRegisterCallBackWorker (\r
   IN  UINTN                       ExTokenNumber,\r
 EFI_STATUS\r
 PeiRegisterCallBackWorker (\r
   IN  UINTN                       ExTokenNumber,\r
@@ -103,16 +103,9 @@ PeiRegisterCallBackWorker (
 \r
 }\r
 \r
 \r
 }\r
 \r
-\r
-\r
-\r
 /**\r
   The function builds the PCD database.\r
 /**\r
   The function builds the PCD database.\r
-\r
-  @param VOID\r
-\r
-  @retval VOID\r
---*/\r
+**/\r
 VOID\r
 BuildPcdDatabase (\r
   VOID\r
 VOID\r
 BuildPcdDatabase (\r
   VOID\r
@@ -137,12 +130,8 @@ BuildPcdDatabase (
   CallbackFnTable = BuildGuidHob (&gPcdPeiCallbackFnTableHobGuid, SizeOfCallbackFnTable);\r
   \r
   ZeroMem (CallbackFnTable, SizeOfCallbackFnTable);\r
   CallbackFnTable = BuildGuidHob (&gPcdPeiCallbackFnTableHobGuid, SizeOfCallbackFnTable);\r
   \r
   ZeroMem (CallbackFnTable, SizeOfCallbackFnTable);\r
-  \r
-  return;\r
 }\r
 \r
 }\r
 \r
-\r
-\r
 /**\r
   The function is provided by PCD PEIM and PCD DXE driver to\r
   do the work of reading a HII variable from variable service.\r
 /**\r
   The function is provided by PCD PEIM and PCD DXE driver to\r
   do the work of reading a HII variable from variable service.\r
@@ -154,8 +143,7 @@ BuildPcdDatabase (
 \r
   @retval EFI_SUCCESS         Operation successful.\r
   @retval EFI_NOT_FOUND         Variablel not found.\r
 \r
   @retval EFI_SUCCESS         Operation successful.\r
   @retval EFI_NOT_FOUND         Variablel not found.\r
---*/\r
-STATIC\r
+**/\r
 EFI_STATUS\r
 GetHiiVariable (\r
   IN  CONST EFI_GUID      *VariableGuid,\r
 EFI_STATUS\r
 GetHiiVariable (\r
   IN  CONST EFI_GUID      *VariableGuid,\r
@@ -201,13 +189,20 @@ GetHiiVariable (
     *VariableData = Buffer;\r
 \r
     return EFI_SUCCESS;\r
     *VariableData = Buffer;\r
 \r
     return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_NOT_FOUND;\r
-  }\r
+  } \r
 \r
 \r
+  return EFI_NOT_FOUND;\r
 }\r
 \r
 }\r
 \r
-STATIC\r
+/**\r
+  Find the local token number according to system SKU ID.\r
+\r
+  @param LocalTokenNumber PCD token number\r
+  @param Size             The size of PCD entry.\r
+\r
+  @return Token number according to system SKU ID.\r
+\r
+**/\r
 UINT32\r
 GetSkuEnabledTokenNumber (\r
   UINT32 LocalTokenNumber,\r
 UINT32\r
 GetSkuEnabledTokenNumber (\r
   UINT32 LocalTokenNumber,\r
@@ -217,7 +212,7 @@ GetSkuEnabledTokenNumber (
   PEI_PCD_DATABASE      *PeiPcdDb;\r
   SKU_HEAD              *SkuHead;\r
   SKU_ID                *SkuIdTable;\r
   PEI_PCD_DATABASE      *PeiPcdDb;\r
   SKU_HEAD              *SkuHead;\r
   SKU_ID                *SkuIdTable;\r
-  INTN                  i;\r
+  INTN                  Index;\r
   UINT8                 *Value;\r
 \r
   PeiPcdDb = GetPcdDatabase ();\r
   UINT8                 *Value;\r
 \r
   PeiPcdDb = GetPcdDatabase ();\r
@@ -228,27 +223,27 @@ GetSkuEnabledTokenNumber (
   Value       = (UINT8 *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuDataStartOffset));\r
   SkuIdTable  = (SKU_ID *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuIdTableOffset));\r
         \r
   Value       = (UINT8 *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuDataStartOffset));\r
   SkuIdTable  = (SKU_ID *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuIdTableOffset));\r
         \r
-  for (i = 0; i < SkuIdTable[0]; i++) {\r
-    if (PeiPcdDb->Init.SystemSkuId == SkuIdTable[i + 1]) {\r
+  for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
+    if (PeiPcdDb->Init.SystemSkuId == SkuIdTable[Index + 1]) {\r
       break;\r
     }\r
   }\r
 \r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
       break;\r
     }\r
   }\r
 \r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
-      Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);\r
+      Value = (UINT8 *) &(((VPD_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_VPD);\r
 \r
     case PCD_TYPE_HII:\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_VPD);\r
 \r
     case PCD_TYPE_HII:\r
-      Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[i]);\r
+      Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);\r
       \r
     case PCD_TYPE_STRING:\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);\r
       \r
     case PCD_TYPE_STRING:\r
-      Value = (UINT8 *) &(((STRING_HEAD *) Value)[i]);\r
+      Value = (UINT8 *) &(((STRING_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);\r
 \r
     case PCD_TYPE_DATA:\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);\r
 \r
     case PCD_TYPE_DATA:\r
-      Value += Size * i;\r
+      Value += Size * Index;\r
       return (UINT32) (Value - (UINT8 *) PeiPcdDb);\r
 \r
     default:\r
       return (UINT32) (Value - (UINT8 *) PeiPcdDb);\r
 \r
     default:\r
@@ -258,12 +253,21 @@ GetSkuEnabledTokenNumber (
   ASSERT (FALSE);\r
 \r
   return 0;\r
   ASSERT (FALSE);\r
 \r
   return 0;\r
-  \r
 }\r
 \r
 }\r
 \r
+/**\r
+  Invoke the callback function when dynamic PCD entry was set, if this PCD entry \r
+  has registered callback function.\r
 \r
 \r
+  @param ExTokenNumber   DynamicEx PCD's token number, if this PCD entry is dyanmicEx\r
+                         type PCD.\r
+  @param Guid            DynamicEx PCD's guid, if this PCD entry is dynamicEx type\r
+                         PCD.\r
+  @param TokenNumber     PCD token number generated by build tools.\r
+  @param Data            Value want to be set for this PCD entry\r
+  @param Size            The size of value\r
 \r
 \r
-STATIC\r
+**/\r
 VOID\r
 InvokeCallbackOnSet (\r
   UINTN             ExTokenNumber,\r
 VOID\r
 InvokeCallbackOnSet (\r
   UINTN             ExTokenNumber,\r
@@ -307,11 +311,18 @@ InvokeCallbackOnSet (
                           );\r
     }\r
   }\r
                           );\r
     }\r
   }\r
-  \r
 }\r
 \r
 }\r
 \r
+/**\r
+  Wrapper function for setting non-pointer type value for a PCD entry.\r
+\r
+  @param TokenNumber     Pcd token number autogenerated by build tools.\r
+  @param Data            Value want to be set for PCD entry\r
+  @param Size            Size of value.\r
 \r
 \r
+  @return status of SetWorker.\r
 \r
 \r
+**/\r
 EFI_STATUS\r
 SetValueWorker (\r
   IN          UINTN              TokenNumber,\r
 EFI_STATUS\r
 SetValueWorker (\r
   IN          UINTN              TokenNumber,\r
@@ -322,12 +333,25 @@ SetValueWorker (
   return SetWorker (TokenNumber, Data, &Size, FALSE);\r
 }\r
 \r
   return SetWorker (TokenNumber, Data, &Size, FALSE);\r
 }\r
 \r
-\r
-\r
+/**\r
+  Set value for an PCD entry\r
+\r
+  @param TokenNumber     Pcd token number autogenerated by build tools.\r
+  @param Data            Value want to be set for PCD entry\r
+  @param Size            Size of value.\r
+  @param PtrType         If TRUE, the type of PCD entry's value is Pointer.\r
+                         If False, the type of PCD entry's value is not Pointer.\r
+\r
+  @retval EFI_INVALID_PARAMETER  If this PCD type is VPD, VPD PCD can not be set.\r
+  @retval EFI_INVALID_PARAMETER  If Size can not be set to size table.\r
+  @retval EFI_NOT_FOUND          If value type of PCD entry is intergrate, but not in\r
+                                 range of UINT8, UINT16, UINT32, UINT64\r
+  @retval EFI_NOT_FOUND          Can not find the PCD type according to token number.                                \r
+**/\r
 EFI_STATUS\r
 SetWorker (\r
   IN          UINTN               TokenNumber,\r
 EFI_STATUS\r
 SetWorker (\r
   IN          UINTN               TokenNumber,\r
-  IN OUT      VOID                *Data,\r
+  IN          VOID                *Data,\r
   IN OUT      UINTN               *Size,\r
   IN          BOOLEAN             PtrType\r
   )\r
   IN OUT      UINTN               *Size,\r
   IN          BOOLEAN             PtrType\r
   )\r
@@ -442,8 +466,17 @@ SetWorker (
 \r
 }\r
 \r
 \r
 }\r
 \r
+/**\r
+  Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.\r
 \r
 \r
+  @param ExTokenNumber   Token number for dynamic-ex PCD.\r
+  @param Guid            Token space guid for dynamic-ex PCD.\r
+  @param Data            Value want to be set.\r
+  @param SetSize         The size of value.\r
 \r
 \r
+  @return status of ExSetWorker().\r
+\r
+**/\r
 EFI_STATUS\r
 ExSetValueWorker (\r
   IN          UINTN                ExTokenNumber,\r
 EFI_STATUS\r
 ExSetValueWorker (\r
   IN          UINTN                ExTokenNumber,\r
@@ -455,8 +488,24 @@ ExSetValueWorker (
   return ExSetWorker (ExTokenNumber, Guid, Data, &Size, FALSE);\r
 }\r
 \r
   return ExSetWorker (ExTokenNumber, Guid, Data, &Size, FALSE);\r
 }\r
 \r
+/**\r
+  Set value for a dynamic PCD entry.\r
+  \r
+  This routine find the local token number according to dynamic-ex PCD's token \r
+  space guid and token number firstly, and invoke callback function if this PCD\r
+  entry registered callback function. Finally, invoken general SetWorker to set\r
+  PCD value.\r
+  \r
+  @param ExTokenNumber   Dynamic-ex PCD token number.\r
+  @param Guid            Token space guid for dynamic-ex PCD.\r
+  @param Data            PCD value want to be set\r
+  @param SetSize         Size of value.\r
+  @param PtrType         If TRUE, this PCD entry is pointer type.\r
+                         If FALSE, this PCD entry is not pointer type.\r
 \r
 \r
+  @return status of SetWorker().\r
 \r
 \r
+**/\r
 EFI_STATUS\r
 ExSetWorker (\r
   IN            UINTN                ExTokenNumber,\r
 EFI_STATUS\r
 ExSetWorker (\r
   IN            UINTN                ExTokenNumber,\r
@@ -480,9 +529,16 @@ ExSetWorker (
 \r
 }\r
 \r
 \r
 }\r
 \r
+/**\r
+  Wrapper function for get PCD value for dynamic-ex PCD.\r
 \r
 \r
+  @param Guid            Token space guid for dynamic-ex PCD.\r
+  @param ExTokenNumber   Token number for dyanmic-ex PCD.\r
+  @param GetSize         The size of dynamic-ex PCD value.\r
 \r
 \r
+  @return PCD entry in PCD database.\r
 \r
 \r
+**/\r
 VOID *\r
 ExGetWorker (\r
   IN CONST  EFI_GUID  *Guid,\r
 VOID *\r
 ExGetWorker (\r
   IN CONST  EFI_GUID  *Guid,\r
@@ -498,13 +554,24 @@ ExGetWorker (
   return GetWorker (GetExPcdTokenNumber (Guid, ExTokenNumber), GetSize);\r
 }\r
 \r
   return GetWorker (GetExPcdTokenNumber (Guid, ExTokenNumber), GetSize);\r
 }\r
 \r
+/**\r
+  Get the PCD entry pointer in PCD database.\r
+  \r
+  This routine will visit PCD database to find the PCD entry according to given\r
+  token number. The given token number is autogened by build tools and it will be \r
+  translated to local token number. Local token number contains PCD's type and \r
+  offset of PCD entry in PCD database.\r
 \r
 \r
+  @param TokenNumber     Token's number, it is autogened by build tools\r
+  @param GetSize         The size of token's value\r
 \r
 \r
+  @return PCD entry pointer in PCD database\r
 \r
 \r
+**/\r
 VOID *\r
 GetWorker (\r
 VOID *\r
 GetWorker (\r
-  UINTN               TokenNumber,\r
-  UINTN               GetSize\r
+  IN UINTN               TokenNumber,\r
+  IN UINTN               GetSize\r
   )\r
 {\r
   UINT32              Offset;\r
   )\r
 {\r
   UINT32              Offset;\r
@@ -596,15 +663,26 @@ GetWorker (
   \r
 }\r
 \r
   \r
 }\r
 \r
+/**\r
+  Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
+\r
+  A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
+  in DEC file. PCD database maintain a mapping table that translate pair of {token\r
+  space guid: token number} to local token number.\r
+  \r
+  @param Guid            Token space guid for dynamic-ex PCD entry.\r
+  @param ExTokenNumber   EDES_TODO: Add parameter description\r
 \r
 \r
+  @return local token number for dynamic-ex PCD.\r
 \r
 \r
+**/\r
 UINTN           \r
 GetExPcdTokenNumber (\r
   IN CONST EFI_GUID             *Guid,\r
   IN UINTN                      ExTokenNumber\r
   )\r
 {\r
 UINTN           \r
 GetExPcdTokenNumber (\r
   IN CONST EFI_GUID             *Guid,\r
   IN UINTN                      ExTokenNumber\r
   )\r
 {\r
-  UINT32              i;\r
+  UINT32              Index;\r
   DYNAMICEX_MAPPING   *ExMap;\r
   EFI_GUID            *GuidTable;\r
   EFI_GUID            *MatchGuid;\r
   DYNAMICEX_MAPPING   *ExMap;\r
   EFI_GUID            *GuidTable;\r
   EFI_GUID            *MatchGuid;\r
@@ -625,10 +703,10 @@ GetExPcdTokenNumber (
   \r
   MatchGuidIdx = MatchGuid - GuidTable;\r
   \r
   \r
   MatchGuidIdx = MatchGuid - GuidTable;\r
   \r
-  for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
-    if ((ExTokenNumber == ExMap[i].ExTokenNumber) && \r
-        (MatchGuidIdx == ExMap[i].ExGuidIndex)) {\r
-      return ExMap[i].LocalTokenNumber;\r
+  for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+    if ((ExTokenNumber == ExMap[Index].ExTokenNumber) && \r
+        (MatchGuidIdx == ExMap[Index].ExGuidIndex)) {\r
+      return ExMap[Index].LocalTokenNumber;\r
     }\r
   }\r
   \r
     }\r
   }\r
   \r
@@ -637,8 +715,12 @@ GetExPcdTokenNumber (
   return 0;\r
 }\r
 \r
   return 0;\r
 }\r
 \r
+/**\r
+  Get PCD database from GUID HOB in PEI phase.\r
 \r
 \r
+  @return Pointer to PCD database.\r
 \r
 \r
+**/\r
 PEI_PCD_DATABASE *\r
 GetPcdDatabase (\r
   VOID\r
 PEI_PCD_DATABASE *\r
 GetPcdDatabase (\r
   VOID\r
@@ -652,8 +734,15 @@ GetPcdDatabase (
   return (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);\r
 }\r
 \r
   return (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);\r
 }\r
 \r
+/**\r
+  Get SKU ID tabble from PCD database.\r
+\r
+  @param LocalTokenNumberTableIdx Index of local token number in token number table.\r
+  @param Database                 PCD database.\r
 \r
 \r
+  @return Pointer to SKU ID array table\r
 \r
 \r
+**/\r
 SKU_ID *\r
 GetSkuIdArray (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
 SKU_ID *\r
 GetSkuIdArray (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
@@ -673,30 +762,37 @@ GetSkuIdArray (
   \r
 }\r
 \r
   \r
 }\r
 \r
+/**\r
+  Get index of PCD entry in size table.\r
+\r
+  @param LocalTokenNumberTableIdx Index of this PCD in local token number table.\r
+  @param Database                 Pointer to PCD database in PEI phase.\r
 \r
 \r
+  @return index of PCD entry in size table.\r
 \r
 \r
+**/\r
 UINTN\r
 GetSizeTableIndex (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
   IN    PEI_PCD_DATABASE  *Database\r
   )\r
 {\r
 UINTN\r
 GetSizeTableIndex (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
   IN    PEI_PCD_DATABASE  *Database\r
   )\r
 {\r
-  UINTN       i;\r
+  UINTN       Index;\r
   UINTN        SizeTableIdx;\r
   UINTN       LocalTokenNumber;\r
   SKU_ID      *SkuIdTable;\r
   \r
   SizeTableIdx = 0;\r
 \r
   UINTN        SizeTableIdx;\r
   UINTN       LocalTokenNumber;\r
   SKU_ID      *SkuIdTable;\r
   \r
   SizeTableIdx = 0;\r
 \r
-  for (i=0; i<LocalTokenNumberTableIdx; i++) {\r
-    LocalTokenNumber = Database->Init.LocalTokenNumberTable[i];\r
+  for (Index=0; Index<LocalTokenNumberTableIdx; Index++) {\r
+    LocalTokenNumber = Database->Init.LocalTokenNumberTable[Index];\r
 \r
     if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) {\r
       //\r
       // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type \r
       // PCD entry.\r
       //\r
 \r
     if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) {\r
       //\r
       // 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
           //\r
           // We have only one entry for VPD enabled PCD entry:\r
           // 1) MAX Size.\r
@@ -717,7 +813,7 @@ GetSizeTableIndex (
           // 1) MAX SIZE\r
           // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r
           //\r
           // 1) MAX SIZE\r
           // 2) Current Size for each SKU_ID (It is equal to MaxSku).\r
           //\r
-          SkuIdTable = GetSkuIdArray (i, Database);\r
+          SkuIdTable = GetSkuIdArray (Index, Database);\r
           SizeTableIdx += (UINTN)*SkuIdTable + 1;\r
         }\r
       }\r
           SizeTableIdx += (UINTN)*SkuIdTable + 1;\r
         }\r
       }\r
index eb7a45d30e03d0c91dd1a19907ab0ab011931e61..006681c49407e91fff4a7130241b616416c3d757 100644 (file)
@@ -15,8 +15,8 @@ Module Name: Service.h
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-#ifndef _SERVICE_H\r
-#define _SERVICE_H\r
+#ifndef _PEI_PCD_SERVICE_H_\r
+#define _PEI_PCD_SERVICE_H_\r
 \r
 #include <PiPei.h>\r
 #include <Ppi/ReadOnlyVariable2.h>\r
 \r
 #include <PiPei.h>\r
 #include <Ppi/ReadOnlyVariable2.h>\r
@@ -48,6 +48,30 @@ Module Name: Service.h
 //\r
 // PPI Interface Implementation Declaration.\r
 //\r
 //\r
 // PPI Interface Implementation Declaration.\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
 VOID\r
 EFIAPI\r
 PeiPcdSetSku (\r
@@ -55,7 +79,17 @@ PeiPcdSetSku (
   )\r
 ;\r
 \r
   )\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
 \r
+  @return The UINT8 value.\r
+  \r
+**/\r
 UINT8\r
 EFIAPI\r
 PeiPcdGet8 (\r
 UINT8\r
 EFIAPI\r
 PeiPcdGet8 (\r
@@ -63,7 +97,17 @@ PeiPcdGet8 (
   )\r
 ;\r
 \r
   )\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
 \r
+  @return The UINT16 value.\r
+  \r
+**/\r
 UINT16\r
 EFIAPI\r
 PeiPcdGet16 (\r
 UINT16\r
 EFIAPI\r
 PeiPcdGet16 (\r
@@ -71,7 +115,17 @@ PeiPcdGet16 (
   )\r
 ;\r
 \r
   )\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
 \r
+  @return The UINT32 value.\r
+  \r
+**/\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32 (\r
 UINT32\r
 EFIAPI\r
 PeiPcdGet32 (\r
@@ -79,7 +133,17 @@ PeiPcdGet32 (
   )\r
 ;\r
 \r
   )\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
 \r
+  @return The UINT64 value.\r
+  \r
+**/\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64 (\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64 (\r
@@ -87,7 +151,19 @@ PeiPcdGet64 (
   )\r
 ;\r
 \r
   )\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
 \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
 VOID *\r
 EFIAPI\r
 PeiPcdGetPtr (\r
@@ -95,7 +171,19 @@ PeiPcdGetPtr (
   )\r
 ;\r
 \r
   )\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
 \r
+  @return The Boolean value.\r
+  \r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBool (\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBool (\r
@@ -103,7 +191,17 @@ PeiPcdGetBool (
   )\r
 ;\r
 \r
   )\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
 \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
 UINTN\r
 EFIAPI\r
 PeiPcdGetSize (\r
@@ -111,7 +209,20 @@ PeiPcdGetSize (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Retrieves an 8-bit value for a given PCD token.\r
 \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]  TokenNumber 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
 UINT8\r
 EFIAPI\r
 PeiPcdGet8Ex (\r
@@ -120,7 +231,20 @@ PeiPcdGet8Ex (
   )\r
 ;\r
 \r
   )\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
 \r
+  @param[in]  Guid The token space for the token number.\r
+  @param[in]  TokenNumber 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
 UINT16\r
 EFIAPI\r
 PeiPcdGet16Ex (\r
@@ -129,6 +253,20 @@ PeiPcdGet16Ex (
   )\r
 ;\r
 \r
   )\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]  TokenNumber 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
 UINT32\r
 EFIAPI\r
 PeiPcdGet32Ex (\r
@@ -137,7 +275,20 @@ PeiPcdGet32Ex (
   )\r
 ;\r
 \r
   )\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]  TokenNumber The PCD token number. \r
 \r
 \r
+  @return The size 64-bit value for the PCD token.\r
+  \r
+**/\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64Ex (\r
 UINT64\r
 EFIAPI\r
 PeiPcdGet64Ex (\r
@@ -146,7 +297,20 @@ PeiPcdGet64Ex (
   )\r
 ;\r
 \r
   )\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
 \r
+  @param[in]  Guid The token space for the token number.\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
 PeiPcdGetPtrEx (\r
 VOID *\r
 EFIAPI\r
 PeiPcdGetPtrEx (\r
@@ -155,7 +319,20 @@ PeiPcdGetPtrEx (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Retrieves an Boolean value for a given PCD token.\r
 \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]  TokenNumber The PCD token number. \r
+\r
+  @return The size Boolean value for the PCD token.\r
+  \r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBoolEx (\r
 BOOLEAN\r
 EFIAPI\r
 PeiPcdGetBoolEx (\r
@@ -164,7 +341,18 @@ PeiPcdGetBoolEx (
   )\r
 ;\r
 \r
   )\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
 \r
+  @param[in]  Guid The token space for the token number.\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
 PeiPcdGetSizeEx (\r
 UINTN\r
 EFIAPI\r
 PeiPcdGetSizeEx (\r
@@ -173,7 +361,23 @@ PeiPcdGetSizeEx (
   )\r
 ;\r
 \r
   )\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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet8 (\r
@@ -182,7 +386,23 @@ PeiPcdSet8 (
   )\r
 ;\r
 \r
   )\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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet16 (\r
@@ -191,7 +411,23 @@ PeiPcdSet16 (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Sets an 32-bit value for a given PCD token.\r
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet32 (\r
@@ -200,7 +436,23 @@ PeiPcdSet32 (
   )\r
 ;\r
 \r
   )\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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet64 (\r
@@ -209,6 +461,27 @@ PeiPcdSet64 (
   )\r
 ;\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]  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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetPtr (\r
@@ -218,7 +491,23 @@ PeiPcdSetPtr (
   )\r
 ;\r
 \r
   )\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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetBool (\r
@@ -227,7 +516,24 @@ PeiPcdSetBool (
   )\r
 ;\r
 \r
   )\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]  TokenNumber The PCD token number. \r
+  @param[in]  Value The value to set for the PCD token.\r
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet8Ex (\r
@@ -237,6 +543,24 @@ PeiPcdSet8Ex (
   )\r
 ;\r
 \r
   )\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]  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
 PeiPcdSet16Ex (\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet16Ex (\r
@@ -246,7 +570,24 @@ PeiPcdSet16Ex (
   )\r
 ;\r
 \r
   )\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
 \r
+  @param[in]  Guid The 128-bit unique value that designates the namespace from which to extract the value.\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
 PeiPcdSet32Ex (\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet32Ex (\r
@@ -256,7 +597,24 @@ PeiPcdSet32Ex (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Sets an 64-bit value for a given PCD token.\r
 \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]  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
 PeiPcdSet64Ex (\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSet64Ex (\r
@@ -266,7 +624,28 @@ PeiPcdSet64Ex (
   )\r
 ;\r
 \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]  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
 PeiPcdSetPtrEx (\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetPtrEx (\r
@@ -277,7 +656,24 @@ PeiPcdSetPtrEx (
   )\r
 ;\r
 \r
   )\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
 \r
+  @param[in]  Guid The 128-bit unique value that designates the namespace from which to extract the value.\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
 PeiPcdSetBoolEx (\r
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdSetBoolEx (\r
@@ -287,8 +683,18 @@ PeiPcdSetBoolEx (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Specifies a function to be called anytime the value of a designated token is changed.\r
 \r
 \r
+  @param[in]  Guid The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]  TokenNumber The PCD token number. \r
+  @param[in]  CallBackFunction The function prototype called when the value associated with the CallBackToken is set.  \r
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiRegisterCallBackOnSet (\r
@@ -298,7 +704,18 @@ PeiRegisterCallBackOnSet (
   )\r
 ;\r
 \r
   )\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]  TokenNumber 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
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PcdUnRegisterCallBackOnSet (\r
 EFI_STATUS\r
 EFIAPI\r
 PcdUnRegisterCallBackOnSet (\r
@@ -308,7 +725,24 @@ PcdUnRegisterCallBackOnSet (
   )\r
 ;\r
 \r
   )\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
 \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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdGetNextToken (\r
@@ -317,24 +751,58 @@ PeiPcdGetNextToken (
   )\r
 ;\r
 \r
   )\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
 EFI_STATUS\r
 EFIAPI\r
 PeiPcdGetNextTokenSpace (\r
-  IN CONST EFI_GUID           **Guid\r
+  IN OUT CONST EFI_GUID           **Guid\r
   )\r
 ;\r
 \r
 \r
 /* Internal Function definitions */\r
   )\r
 ;\r
 \r
 \r
 /* Internal Function definitions */\r
+/**\r
+  Get PCD database from GUID HOB in PEI phase.\r
+\r
+  @return Pointer to PCD database.\r
 \r
 \r
+**/\r
 PEI_PCD_DATABASE *\r
 GetPcdDatabase (\r
   VOID\r
   )\r
 ;\r
 \r
 PEI_PCD_DATABASE *\r
 GetPcdDatabase (\r
   VOID\r
   )\r
 ;\r
 \r
+/**\r
+  Wrapper function for setting non-pointer type value for a PCD entry.\r
+\r
+  @param TokenNumber     Pcd token number autogenerated by build tools.\r
+  @param Data            Value want to be set for PCD entry\r
+  @param Size            Size of value.\r
 \r
 \r
+  @return status of SetWorker.\r
+\r
+**/\r
 EFI_STATUS\r
 SetValueWorker (\r
   IN          UINTN              TokenNumber,\r
 EFI_STATUS\r
 SetValueWorker (\r
   IN          UINTN              TokenNumber,\r
@@ -343,7 +811,21 @@ SetValueWorker (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Set value for an PCD entry\r
 \r
 \r
+  @param TokenNumber     Pcd token number autogenerated by build tools.\r
+  @param Data            Value want to be set for PCD entry\r
+  @param Size            Size of value.\r
+  @param PtrType         If TRUE, the type of PCD entry's value is Pointer.\r
+                         If False, the type of PCD entry's value is not Pointer.\r
+\r
+  @retval EFI_INVALID_PARAMETER  If this PCD type is VPD, VPD PCD can not be set.\r
+  @retval EFI_INVALID_PARAMETER  If Size can not be set to size table.\r
+  @retval EFI_NOT_FOUND          If value type of PCD entry is intergrate, but not in\r
+                                 range of UINT8, UINT16, UINT32, UINT64\r
+  @retval EFI_NOT_FOUND          Can not find the PCD type according to token number.                                \r
+**/\r
 EFI_STATUS\r
 SetWorker (\r
   IN          UINTN              TokenNumber,\r
 EFI_STATUS\r
 SetWorker (\r
   IN          UINTN              TokenNumber,\r
@@ -353,7 +835,17 @@ SetWorker (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.\r
 \r
 \r
+  @param ExTokenNumber   Token number for dynamic-ex PCD.\r
+  @param Guid            Token space guid for dynamic-ex PCD.\r
+  @param Data            Value want to be set.\r
+  @param SetSize         The size of value.\r
+\r
+  @return status of ExSetWorker().\r
+\r
+**/\r
 EFI_STATUS\r
 ExSetValueWorker (\r
   IN          UINTN                ExTokenNumber,\r
 EFI_STATUS\r
 ExSetValueWorker (\r
   IN          UINTN                ExTokenNumber,\r
@@ -363,8 +855,24 @@ ExSetValueWorker (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Set value for a dynamic PCD entry.\r
+  \r
+  This routine find the local token number according to dynamic-ex PCD's token \r
+  space guid and token number firstly, and invoke callback function if this PCD\r
+  entry registered callback function. Finally, invoken general SetWorker to set\r
+  PCD value.\r
+  \r
+  @param ExTokenNumber   Dynamic-ex PCD token number.\r
+  @param Guid            Token space guid for dynamic-ex PCD.\r
+  @param Data            PCD value want to be set\r
+  @param SetSize         Size of value.\r
+  @param PtrType         If TRUE, this PCD entry is pointer type.\r
+                         If FALSE, this PCD entry is not pointer type.\r
+\r
+  @return status of SetWorker().\r
 \r
 \r
-\r
+**/\r
 EFI_STATUS\r
 ExSetWorker (\r
   IN      UINTN                ExTokenNumber,\r
 EFI_STATUS\r
 ExSetWorker (\r
   IN      UINTN                ExTokenNumber,\r
@@ -375,8 +883,20 @@ ExSetWorker (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Get the PCD entry pointer in PCD database.\r
+  \r
+  This routine will visit PCD database to find the PCD entry according to given\r
+  token number. The given token number is autogened by build tools and it will be \r
+  translated to local token number. Local token number contains PCD's type and \r
+  offset of PCD entry in PCD database.\r
+\r
+  @param TokenNumber     Token's number, it is autogened by build tools\r
+  @param GetSize         The size of token's value\r
 \r
 \r
+  @return PCD entry pointer in PCD database\r
 \r
 \r
+**/\r
 VOID *\r
 GetWorker (\r
   IN UINTN                TokenNumber,\r
 VOID *\r
 GetWorker (\r
   IN UINTN                TokenNumber,\r
@@ -384,8 +904,16 @@ GetWorker (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Wrapper function for get PCD value for dynamic-ex PCD.\r
+\r
+  @param Guid            Token space guid for dynamic-ex PCD.\r
+  @param ExTokenNumber   Token number for dyanmic-ex PCD.\r
+  @param GetSize         The size of dynamic-ex PCD value.\r
 \r
 \r
+  @return PCD entry in PCD database.\r
 \r
 \r
+**/\r
 VOID *\r
 ExGetWorker (\r
   IN CONST EFI_GUID   *Guid,\r
 VOID *\r
 ExGetWorker (\r
   IN CONST EFI_GUID   *Guid,\r
@@ -400,7 +928,19 @@ typedef struct {
   UINT32  LocalTokenNumberAlias;\r
 } EX_PCD_ENTRY_ATTRIBUTE;\r
 \r
   UINT32  LocalTokenNumberAlias;\r
 } EX_PCD_ENTRY_ATTRIBUTE;\r
 \r
+/**\r
+  Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
+\r
+  A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
+  in DEC file. PCD database maintain a mapping table that translate pair of {token\r
+  space guid: token number} to local token number.\r
+  \r
+  @param Guid            Token space guid for dynamic-ex PCD entry.\r
+  @param ExTokenNumber   EDES_TODO: Add parameter description\r
 \r
 \r
+  @return local token number for dynamic-ex PCD.\r
+\r
+**/\r
 UINTN\r
 GetExPcdTokenNumber (\r
   IN CONST EFI_GUID             *Guid,\r
 UINTN\r
 GetExPcdTokenNumber (\r
   IN CONST EFI_GUID             *Guid,\r
@@ -408,26 +948,46 @@ GetExPcdTokenNumber (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  The function registers the CallBackOnSet fucntion\r
+  according to TokenNumber and EFI_GUID space.\r
 \r
 \r
+  @param  TokenNumber       The token number.\r
+  @param  Guid              The GUID space.\r
+  @param  CallBackFunction  The Callback function to be registered.\r
+  @param  Register          To register or unregister the callback function.\r
 \r
 \r
-\r
+  @retval EFI_SUCCESS If the Callback function is registered.\r
+  @retval EFI_NOT_FOUND If the PCD Entry is not found according to Token Number and GUID space.\r
+  @retval EFI_OUT_OF_RESOURCES If the callback function can't be registered because there is not free\r
+                                slot left in the CallbackFnTable.\r
+**/\r
 EFI_STATUS\r
 PeiRegisterCallBackWorker (\r
   IN  UINTN              TokenNumber,\r
 EFI_STATUS\r
 PeiRegisterCallBackWorker (\r
   IN  UINTN              TokenNumber,\r
-  IN  CONST GUID         *Guid, OPTIONAL\r
+  IN  CONST EFI_GUID         *Guid, OPTIONAL\r
   IN  PCD_PPI_CALLBACK   CallBackFunction,\r
   IN  BOOLEAN            Register\r
 );\r
 \r
   IN  PCD_PPI_CALLBACK   CallBackFunction,\r
   IN  BOOLEAN            Register\r
 );\r
 \r
-\r
-\r
-\r
+/**\r
+  The function builds the PCD database.\r
+**/\r
 VOID\r
 BuildPcdDatabase (\r
   VOID\r
   )\r
 ;\r
 \r
 VOID\r
 BuildPcdDatabase (\r
   VOID\r
   )\r
 ;\r
 \r
+/**\r
+  Get SKU ID tabble from PCD database.\r
+\r
+  @param LocalTokenNumberTableIdx Index of local token number in token number table.\r
+  @param Database                 PCD Database in PEI phase\r
+\r
+  @return Pointer to SKU ID array table\r
+\r
+**/\r
 SKU_ID *\r
 GetSkuIdArray (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
 SKU_ID *\r
 GetSkuIdArray (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
@@ -435,6 +995,15 @@ GetSkuIdArray (
   )\r
 ;\r
 \r
   )\r
 ;\r
 \r
+/**\r
+  Get index of PCD entry in size table.\r
+\r
+  @param LocalTokenNumberTableIdx Index of this PCD in local token number table.\r
+  @param Database                 Pointer to PCD database.\r
+\r
+  @return index of PCD entry in size table.\r
+\r
+**/\r
 UINTN\r
 GetSizeTableIndex (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
 UINTN\r
 GetSizeTableIndex (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
@@ -442,6 +1011,19 @@ GetSizeTableIndex (
   )\r
 ;\r
 \r
   )\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
 UINTN\r
 GetPtrTypeSize (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
@@ -450,8 +1032,20 @@ GetPtrTypeSize (
   )\r
 ;\r
 \r
   )\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
 \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
 \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
 BOOLEAN\r
 SetPtrTypeSize (\r
   IN          UINTN             LocalTokenNumberTableIdx,\r