]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Dxe/Pcd.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Pcd.c
index 0c44a64077cf0882c5619929b683bef2b6c3259c..3cd805a88df3aee37ef1c1af202bbff048e4b872 100644 (file)
@@ -1,9 +1,10 @@
 /** @file\r
   PCD DXE driver manage all PCD entry initialized in PEI phase and DXE phase, and\r
-  produce the implementation of PCD protocol.\r
+  produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in\r
+  PI 1.2 Vol3.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2010, 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
@@ -25,8 +26,12 @@ EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZ
 ///\r
 /// PCD database lock.\r
 ///\r
-EFI_LOCK mPcdDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_CALLBACK);\r
+EFI_LOCK mPcdDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_NOTIFY);\r
 \r
+///\r
+/// PCD_PROTOCOL the EDKII native implementation which support dynamic \r
+/// type and dynamicEx type PCDs.\r
+///\r
 PCD_PROTOCOL mPcdInstance = {\r
   DxePcdSetSku,\r
 \r
@@ -66,11 +71,32 @@ PCD_PROTOCOL mPcdInstance = {
   DxePcdGetNextTokenSpace\r
 };\r
 \r
+///\r
+/// EFI_PCD_PROTOCOL is defined in PI 1.2 Vol 3 which only support dynamicEx type\r
+/// PCD.\r
+///\r
+EFI_PCD_PROTOCOL mEfiPcdInstance = {\r
+  DxePcdSetSku,\r
+  DxePcdGet8Ex,\r
+  DxePcdGet16Ex,\r
+  DxePcdGet32Ex,\r
+  DxePcdGet64Ex,\r
+  DxePcdGetPtrEx,\r
+  DxePcdGetBoolEx,\r
+  DxePcdGetSizeEx,\r
+  DxePcdSet8Ex,\r
+  DxePcdSet16Ex,\r
+  DxePcdSet32Ex,\r
+  DxePcdSet64Ex,\r
+  DxePcdSetPtrEx,\r
+  DxePcdSetBoolEx,\r
+  (EFI_PCD_PROTOCOL_CALLBACK_ON_SET) DxeRegisterCallBackOnSet,\r
+  (EFI_PCD_PROTOCOL_CANCEL_CALLBACK) DxeUnRegisterCallBackOnSet,\r
+  DxePcdGetNextToken,\r
+  DxePcdGetNextTokenSpace\r
+};\r
 \r
-//\r
-// Static global to reduce the code size\r
-//\r
-EFI_HANDLE mNewHandle = NULL;\r
+EFI_HANDLE mPcdHandle = NULL;\r
 \r
 /**\r
   Main entry for PCD DXE driver.\r
@@ -90,8 +116,8 @@ PcdDxeInit (
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
-  EFI_STATUS          Status;\r
-\r
+  EFI_STATUS Status;\r
+  \r
   //\r
   // Make sure the Pcd Protocol is not already installed in the system\r
   //\r
@@ -100,16 +126,20 @@ PcdDxeInit (
 \r
   BuildPcdDxeDataBase ();\r
 \r
-  Status = gBS->InstallProtocolInterface (\r
-                  &mNewHandle,\r
-                  &gPcdProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &mPcdInstance\r
+  //\r
+  // Install PCD_PROTOCOL to handle dynamic type PCD\r
+  // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &mPcdHandle,\r
+                  &gPcdProtocolGuid,     &mPcdInstance,\r
+                  &gEfiPcdProtocolGuid,  &mEfiPcdInstance,\r
+                  NULL\r
                   );\r
-\r
+                 \r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 \r
 }\r
 \r
@@ -920,18 +950,28 @@ DxeUnRegisterCallBackOnSet (
 }\r
 \r
 /**\r
-  Retrieves the next valid PCD token for a given namespace.\r
-\r
-  @param[in]      Guid          The 128-bit unique value that designates the namespace from which to extract the value.\r
-  @param[in, out]  TokenNumber   A pointer to the PCD token number to use to find the subsequent token number.  \r
-                                If the input token namespace or token number does not exist on the platform, \r
-                                an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token, \r
-                                have the pointer reference a TokenNumber value of 0. If the input token number is 0 and \r
-                                there is no valid token number for this token namespace,  *TokenNumber will be assigned to \r
-                                0 and the function return EFI_SUCCESS. If the token number is the last valid token number, \r
-                                *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.\r
-\r
-  @retval EFI_SUCCESS  The PCD service retrieved the next valid token number. Or the input token number \r
+  Retrieves the next valid token number in a given namespace.  \r
+  \r
+  This is useful since the PCD infrastructure contains a sparse list of token numbers, \r
+  and one cannot a priori know what token numbers are valid in the database. \r
+  \r
+  If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.  \r
+  If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.  \r
+  If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.  \r
+  If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.  \r
+  The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.  \r
+  If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.  \r
+  If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.  \r
+  If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.\r
+\r
+\r
+  @param[in]      Guid    The 128-bit unique value that designates the namespace from which to retrieve the next token. \r
+                          This is an optional parameter that may be NULL.  If this parameter is NULL, then a request is \r
+                          being made to retrieve tokens from the default token space.\r
+  @param[in, out] TokenNumber \r
+                          A pointer to the PCD token number to use to find the subsequent token number.  \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
@@ -948,10 +988,6 @@ DxePcdGetNextToken (
   BOOLEAN             PeiExMapTableEmpty;\r
   BOOLEAN             DxeExMapTableEmpty;\r
 \r
-  if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
   Status = EFI_NOT_FOUND;\r
   PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r
   DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;\r
@@ -1065,14 +1101,11 @@ GetDistinctTokenSpace (
 /**\r
   Get next token space in PCD database according to given token space guid.\r
   \r
-  This routine is enable only when feature flag PCD PcdDxePcdDatabaseTraverseEnabled \r
-  is TRUE.\r
-  \r
   @param Guid            Given token space guid. If NULL, then Guid will be set to \r
                          the first PCD token space in PCD database, If not NULL, then\r
                          Guid will be set to next PCD token space.\r
 \r
-  @retval EFI_UNSUPPORTED If feature flag PCD PcdDxePcdDatabaseTraverseEnabled is FALSE.\r
+  @retval EFI_UNSUPPORTED \r
   @retval EFI_NOT_FOUND   If PCD database has no token space table or can not find given\r
                           token space in PCD database.\r
   @retval EFI_SUCCESS     Success to get next token space guid.\r
@@ -1094,10 +1127,6 @@ DxePcdGetNextTokenSpace (
   BOOLEAN             PeiExMapTableEmpty;\r
   BOOLEAN             DxeExMapTableEmpty;\r
 \r
-  if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
   ASSERT (Guid != NULL);\r
   \r
   PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r