]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Pei/Service.h
MdeModulePkg: Update PCD driver to support the optimized PcdDataBase
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Service.h
index b5c2a872a80cfe5c12bab59c886a785b752d325c..3a7910a900c8261ccbc2bf428b953e516acf8865 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   The internal header file declares the private functions used by PeiPcd driver.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -19,7 +19,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Ppi/ReadOnlyVariable2.h>\r
 #include <Ppi/Pcd.h>\r
 #include <Ppi/PiPcd.h>\r
+#include <Ppi/PcdInfo.h>\r
+#include <Ppi/PiPcdInfo.h>\r
 #include <Guid/PcdDataBaseHobGuid.h>\r
+#include <Guid/PcdDataBaseSignatureGuid.h>\r
+#include <Guid/VariableFormat.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/BaseLib.h>\r
@@ -27,21 +31,75 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/PeiServicesLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
-\r
+#include <Library/MemoryAllocationLib.h>\r
 \r
 //\r
 // Please make sure the PCD Serivce PEIM Version is consistent with\r
-// the version of PCD Database generation tool\r
+// the version of the generated PEIM PCD Database by build tool.\r
 //\r
-#define PCD_SERVICE_PEIM_VERSION      2\r
+#define PCD_SERVICE_PEIM_VERSION      7\r
 \r
 //\r
-// PCD_PEI_DATABASE_GENTOOL_VERSION is defined in Autogen.h\r
-// and generated by PCD Database generation tool.\r
+// PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.\r
 //\r
-//#if (PCD_SERVICE_PEIM_VERSION != PCD_PEI_SERVICE_DRIVER_AUTOGEN_VERSION )\r
-//  #error "Please make sure the version of PCD Service PEIM and PCD PEI Database Generation Tool matches"\r
-//#endif\r
+#if (PCD_SERVICE_PEIM_VERSION != PCD_PEI_SERVICE_DRIVER_VERSION)\r
+  #error "Please make sure the version of PCD PEIM Service and the generated PCD PEI Database match."\r
+#endif\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token in the default token space.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetPcdInfoGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\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[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetPcdInfoGetInfoEx (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+PeiGetPcdInfoGetSku (\r
+  VOID\r
+  );\r
 \r
 //\r
 // PPI Interface Implementation Declaration.\r
@@ -753,6 +811,26 @@ PeiPcdGetNextTokenSpace (
   IN OUT CONST EFI_GUID           **Guid\r
   );\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\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[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. \r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+PeiGetPcdInfo (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
 \r
 /* Internal Function definitions */\r
 /**\r
@@ -794,6 +872,7 @@ SetValueWorker (
 \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_INVALID_PARAMETER  If Size of non-Ptr type PCD does not match the size information in PCD database.\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
@@ -896,16 +975,16 @@ typedef struct {
 } EX_PCD_ENTRY_ATTRIBUTE;\r
 \r
 /**\r
-  Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
+  Get 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
+  space guid: token number} to Token Number.\r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   @param ExTokenNumber   Token number for dynamic-ex PCD.\r
 \r
-  @return local token number for dynamic-ex PCD.\r
+  @return Token Number for dynamic-ex PCD.\r
 \r
 **/\r
 UINTN\r
@@ -938,25 +1017,15 @@ PeiRegisterCallBackWorker (
 \r
 /**\r
   The function builds the PCD database.\r
-**/\r
-VOID\r
-BuildPcdDatabase (\r
-  VOID\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
+  @param  FileHandle  Handle of the file the external PCD database binary located.\r
 \r
-  @return Pointer to SKU ID array table\r
+  @return Pointer to PCD database.\r
 \r
 **/\r
-SKU_ID *\r
-GetSkuIdArray (\r
-  IN    UINTN             LocalTokenNumberTableIdx,\r
-  IN    PEI_PCD_DATABASE  *Database\r
+PEI_PCD_DATABASE *\r
+BuildPcdDatabase (\r
+  IN EFI_PEI_FILE_HANDLE    FileHandle\r
   );\r
 \r
 /**\r
@@ -1015,10 +1084,5 @@ SetPtrTypeSize (
   IN          PEI_PCD_DATABASE  *Database\r
   );\r
 \r
-//\r
-// The init Database created by PCD Database generation tool\r
-//\r
-extern PEI_PCD_DATABASE_INIT gPEIPcdDbInit;\r
-\r
 #endif\r
 \r