* [PATCH 0/2] New feature to enable standalone PCD driver @ 2021-05-24 9:24 Zhiguang Liu 2021-05-24 9:24 ` [PATCH 1/2] MdePkg: Standalone " Zhiguang Liu 2021-05-24 9:24 ` [PATCH 2/2] UefiPayloadPkg: Use standalone " Zhiguang Liu 0 siblings, 2 replies; 10+ messages in thread From: Zhiguang Liu @ 2021-05-24 9:24 UTC (permalink / raw) To: devel There are cases that different binary is build differently, and both want to use PCD feature. If these two different don't want to use PCD to communicate, they should have a standalone PCD data base, For example, bootloader and payload want to have seperately PCD data base. Zhiguang Liu (2): MdePkg: Standalone PCD driver UefiPayloadPkg: Use standalone PCD driver MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++------------------------ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- MdePkg/Include/Protocol/Pcd.h | 5 ----- MdePkg/Include/Protocol/PcdInfo.h | 5 ----- MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 ++++++++++++++++++++---- MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MdePkg/MdePkg.dec | 12 ++++++++++++ UefiPayloadPkg/UefiPayloadPkg.dsc | 9 +++++---- 10 files changed, 189 insertions(+), 51 deletions(-) create mode 100644 MdePkg/Library/DxePcdLib/PayloadPcdLib.inf -- 2.30.0.windows.2 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-24 9:24 [PATCH 0/2] New feature to enable standalone PCD driver Zhiguang Liu @ 2021-05-24 9:24 ` Zhiguang Liu 2021-05-24 20:29 ` [edk2-devel] " Michael D Kinney 2021-05-24 9:24 ` [PATCH 2/2] UefiPayloadPkg: Use standalone " Zhiguang Liu 1 sibling, 1 reply; 10+ messages in thread From: Zhiguang Liu @ 2021-05-24 9:24 UTC (permalink / raw) To: devel; +Cc: Michael D Kinney, Liming Gao Add a feature PCD to control if the PCD driver is build as standalone mode. This way, two mode PCD driver won't share the data base. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> --- MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++------------------------ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- MdePkg/Include/Protocol/Pcd.h | 5 ----- MdePkg/Include/Protocol/PcdInfo.h | 5 ----- MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 ++++++++++++++++++++---- MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MdePkg/MdePkg.dec | 12 ++++++++++++ 9 files changed, 184 insertions(+), 47 deletions(-) diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c index cdb9b4fac1..dc9c4be022 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c @@ -129,34 +129,61 @@ PcdDxeInit ( // // Make sure the Pcd Protocol is not already installed in the system // + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEdkiiPayloadStandalonePcdProtocolGuid); + BuildPcdDxeDataBase (); - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); + // + // Install PCD_PROTOCOL to handle dynamic type PCD + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mPcdHandle, + &gEdkiiPayloadStandalonePcdProtocolGuid, &mPcdInstance, + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, &mEfiPcdInstance, + NULL + ); + ASSERT_EFI_ERROR (Status); - BuildPcdDxeDataBase (); + // + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mPcdHandle, + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, &mGetPcdInfoInstance, + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, + NULL + ); + ASSERT_EFI_ERROR (Status); + } else { + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); + BuildPcdDxeDataBase (); - // - // Install PCD_PROTOCOL to handle dynamic type PCD - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mPcdHandle, - &gPcdProtocolGuid, &mPcdInstance, - &gEfiPcdProtocolGuid, &mEfiPcdInstance, - NULL - ); - ASSERT_EFI_ERROR (Status); + // + // Install PCD_PROTOCOL to handle dynamic type PCD + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mPcdHandle, + &gPcdProtocolGuid, &mPcdInstance, + &gEfiPcdProtocolGuid, &mEfiPcdInstance, + NULL + ); + ASSERT_EFI_ERROR (Status); - // - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mPcdHandle, - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, - NULL - ); - ASSERT_EFI_ERROR (Status); + // + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mPcdHandle, + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, + &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, + NULL + ); + ASSERT_EFI_ERROR (Status); + } // // Register callback function upon VariableLockProtocol diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf index eb9f757f14..f3e704f083 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf @@ -329,10 +329,15 @@ gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES ## GUID [Protocols] - gPcdProtocolGuid ## PRODUCES - gEfiPcdProtocolGuid ## PRODUCES - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES + gPcdProtocolGuid ## PRODUCES + gEfiPcdProtocolGuid ## PRODUCES + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES + + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES ## NOTIFY ## SOMETIMES_CONSUMES gEdkiiVariableLockProtocolGuid @@ -342,6 +347,9 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## SOMETIMES_CONSUMES +[FeaturePcd] + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES + [Depex] TRUE diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c index ea7edc3cbb..fe16ba713b 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length); mPcdDatabase.DxeDb = PcdDxeDb; - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { + GuidHob = NULL; + } else { + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); + } + if (GuidHob != NULL) { // diff --git a/MdePkg/Include/Protocol/Pcd.h b/MdePkg/Include/Protocol/Pcd.h index 9cd1a998f8..cfa6ac2360 100644 --- a/MdePkg/Include/Protocol/Pcd.h +++ b/MdePkg/Include/Protocol/Pcd.h @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __PCD_H__ #define __PCD_H__ -extern EFI_GUID gPcdProtocolGuid; - -#define PCD_PROTOCOL_GUID \ - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, 0xe, 0xf7 } } - #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) diff --git a/MdePkg/Include/Protocol/PcdInfo.h b/MdePkg/Include/Protocol/PcdInfo.h index b0ec7f6770..5691215c42 100644 --- a/MdePkg/Include/Protocol/PcdInfo.h +++ b/MdePkg/Include/Protocol/PcdInfo.h @@ -19,11 +19,6 @@ #ifndef __PCD_INFO_H__ #define __PCD_INFO_H__ -extern EFI_GUID gGetPcdInfoProtocolGuid; - -#define GET_PCD_INFO_PROTOCOL_GUID \ - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } - /// /// The forward declaration for GET_PCD_INFO_PROTOCOL. /// diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c index 2accaeda2c..8a61486832 100644 --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c @@ -43,7 +43,11 @@ GetPiPcdProtocol ( // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module // access DynamicEx type PCD. // - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) &mPiPcd); + } else { + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); + } ASSERT_EFI_ERROR (Status); ASSERT (mPiPcd != NULL); } @@ -68,7 +72,11 @@ GetPcdProtocol ( // PCD protocol need to be installed before the module access Dynamic type PCD. // But dynamic type PCD is not required in PI 1.2 specification. // - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { + Status = gBS->LocateProtocol (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); + } else { + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); + } ASSERT_EFI_ERROR (Status); ASSERT (mPcd != NULL); } @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( EFI_STATUS Status; if (mPiPcdInfo == NULL) { - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); + } else{ + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); + } ASSERT_EFI_ERROR (Status); ASSERT (mPiPcdInfo != NULL); } @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( EFI_STATUS Status; if (mPcdInfo == NULL) { - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { + Status = gBS->LocateProtocol (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); + } else { + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); + } ASSERT_EFI_ERROR (Status); ASSERT (mPcdInfo != NULL); } diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf b/MdePkg/Library/DxePcdLib/DxePcdLib.inf index 3d4d21b442..59d9fe4f11 100644 --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf @@ -53,10 +53,18 @@ [Protocols] - gPcdProtocolGuid ## SOMETIMES_CONSUMES - gEfiPcdProtocolGuid ## CONSUMES - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES + gPcdProtocolGuid ## SOMETIMES_CONSUMES + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES + + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES + +[FeaturePcd] + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] gEfiPcdProtocolGuid diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf new file mode 100644 index 0000000000..e61296e11a --- /dev/null +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf @@ -0,0 +1,71 @@ +## @file +# Instance of PCD Library using PCD Protocol. +# +# There are two PCD protocols as follows: +# 1) PCD_PROTOCOL +# It is EDKII implementation which support Dynamic/DynamicEx Pcds. +# 2) EFI_PCD_PROTOCOL +# It is defined by PI specification 1.2, Vol 3 which only support dynamicEx +# type Pcd. +# +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL. +# +# This library instance uses the PCD_PROTOCOL to handle dynamic PCD request and use +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. +# +# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can only use this DxePcdLib +# in their initialization without any issues to access Dynamic and DynamicEx PCD. They can't +# access Dynamic and DynamicEx PCD in the implementation of runtime services and SMI handlers. +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in OS runtime phase. +# +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = DxePcdLib + MODULE_UNI_FILE = DxePcdLib.uni + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVER + +# +# VALID_ARCHITECTURES = IA32 X64 EBC +# + +[Sources] + DxePcdLib.c + + +[Packages] + MdePkg/MdePkg.dec + + +[LibraryClasses] + BaseMemoryLib + UefiBootServicesTableLib + DebugLib + + +[Protocols] + gPcdProtocolGuid ## SOMETIMES_CONSUMES + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES + + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES + +[FeaturePcd] + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES + +[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] + gEdkiiEfiPayloadStandalonePcdProtocolGuid + diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index b49f88d8e1..44f60e2086 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -1000,6 +1000,12 @@ ## Include/Protocol/PcdInfo.h gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } + ## Payload Standalone Pcd Protocol + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, 0x7d, 0xc9, 0x1f}} + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, 0xae76, 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, 0x04, 0x4d, 0xea}} + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, 0x14, 0x5e, 0x15}} + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, 0xa9, 0x68, 0x9e}} + # # Protocols defined in PI1.0. # @@ -1945,6 +1951,12 @@ # @Prompt Validate ORDERED_COLLECTION structure gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEAN|0x0000002a + ## Indicates if the standalone PCD database is enabled for Payload.<BR><BR> + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> + # FALSE - Disable tandalone PCD database is enabled for Payload.<BR> + # @Prompt Enable tandalone PCD database is enabled for Payload. + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOOLEAN|0x0000002e + [PcdsFixedAtBuild] ## Status code value for indicating a watchdog timer has expired. # EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_TIMER_EXPIRED -- 2.30.0.windows.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-24 9:24 ` [PATCH 1/2] MdePkg: Standalone " Zhiguang Liu @ 2021-05-24 20:29 ` Michael D Kinney 2021-05-25 1:09 ` Zhiguang Liu 2021-05-25 1:33 ` Ni, Ray 0 siblings, 2 replies; 10+ messages in thread From: Michael D Kinney @ 2021-05-24 20:29 UTC (permalink / raw) To: devel@edk2.groups.io, Liu, Zhiguang, Kinney, Michael D; +Cc: Liming Gao Why do we need a new PCD? Can't we make this the default behavior to only install one instance? Thanks, Mike > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Zhiguang Liu > Sent: Monday, May 24, 2021 2:25 AM > To: devel@edk2.groups.io > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn> > Subject: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > Add a feature PCD to control if the PCD driver is build as standalone mode. > This way, two mode PCD driver won't share the data base. > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > --- > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- > -- > MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- > MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- > MdePkg/Include/Protocol/Pcd.h | 5 ----- > MdePkg/Include/Protocol/PcdInfo.h | 5 ----- > MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 ++++++++++++++++++++---- > MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- > MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > MdePkg/MdePkg.dec | 12 ++++++++++++ > 9 files changed, 184 insertions(+), 47 deletions(-) > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > index cdb9b4fac1..dc9c4be022 100644 > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > @@ -129,34 +129,61 @@ PcdDxeInit ( > // > > // Make sure the Pcd Protocol is not already installed in the system > > // > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEdkiiPayloadStandalonePcdProtocolGuid); > > + BuildPcdDxeDataBase (); > > > > - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > + // > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > + // > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > + &mPcdHandle, > > + &gEdkiiPayloadStandalonePcdProtocolGuid, &mPcdInstance, > > + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, &mEfiPcdInstance, > > + NULL > > + ); > > + ASSERT_EFI_ERROR (Status); > > > > - BuildPcdDxeDataBase (); > > + // > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > + // > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > + &mPcdHandle, > > + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, &mGetPcdInfoInstance, > > + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > + NULL > > + ); > > + ASSERT_EFI_ERROR (Status); > > + } else { > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > + BuildPcdDxeDataBase (); > > > > - // > > - // Install PCD_PROTOCOL to handle dynamic type PCD > > - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > - // > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > - &mPcdHandle, > > - &gPcdProtocolGuid, &mPcdInstance, > > - &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > - NULL > > - ); > > - ASSERT_EFI_ERROR (Status); > > + // > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > + // > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > + &mPcdHandle, > > + &gPcdProtocolGuid, &mPcdInstance, > > + &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > + NULL > > + ); > > + ASSERT_EFI_ERROR (Status); > > > > - // > > - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > - // > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > - &mPcdHandle, > > - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > - NULL > > - ); > > - ASSERT_EFI_ERROR (Status); > > + // > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > + // > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > + &mPcdHandle, > > + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > + &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > + NULL > > + ); > > + ASSERT_EFI_ERROR (Status); > > + } > > > > // > > // Register callback function upon VariableLockProtocol > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > index eb9f757f14..f3e704f083 100644 > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > @@ -329,10 +329,15 @@ > gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES ## GUID > > > > [Protocols] > > - gPcdProtocolGuid ## PRODUCES > > - gEfiPcdProtocolGuid ## PRODUCES > > - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > + gPcdProtocolGuid ## PRODUCES > > + gEfiPcdProtocolGuid ## PRODUCES > > + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > + > > + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > ## NOTIFY > > ## SOMETIMES_CONSUMES > > gEdkiiVariableLockProtocolGuid > > @@ -342,6 +347,9 @@ > gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## SOMETIMES_CONSUMES > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## SOMETIMES_CONSUMES > > > > +[FeaturePcd] > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > + > > [Depex] > > TRUE > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c > index ea7edc3cbb..fe16ba713b 100644 > --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c > +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c > @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( > CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length); > > mPcdDatabase.DxeDb = PcdDxeDb; > > > > - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > + GuidHob = NULL; > > + } else { > > + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > + } > > + > > if (GuidHob != NULL) { > > > > // > > diff --git a/MdePkg/Include/Protocol/Pcd.h b/MdePkg/Include/Protocol/Pcd.h > index 9cd1a998f8..cfa6ac2360 100644 > --- a/MdePkg/Include/Protocol/Pcd.h > +++ b/MdePkg/Include/Protocol/Pcd.h > @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #ifndef __PCD_H__ > > #define __PCD_H__ > > > > -extern EFI_GUID gPcdProtocolGuid; > > - > > -#define PCD_PROTOCOL_GUID \ > > - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, 0xe, 0xf7 } } > > - > > #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) > > > > > > diff --git a/MdePkg/Include/Protocol/PcdInfo.h b/MdePkg/Include/Protocol/PcdInfo.h > index b0ec7f6770..5691215c42 100644 > --- a/MdePkg/Include/Protocol/PcdInfo.h > +++ b/MdePkg/Include/Protocol/PcdInfo.h > @@ -19,11 +19,6 @@ > #ifndef __PCD_INFO_H__ > > #define __PCD_INFO_H__ > > > > -extern EFI_GUID gGetPcdInfoProtocolGuid; > > - > > -#define GET_PCD_INFO_PROTOCOL_GUID \ > > - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > - > > /// > > /// The forward declaration for GET_PCD_INFO_PROTOCOL. > > /// > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c > index 2accaeda2c..8a61486832 100644 > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c > @@ -43,7 +43,11 @@ GetPiPcdProtocol ( > // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module > > // access DynamicEx type PCD. > > // > > - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > + } else { > > + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > + } > > ASSERT_EFI_ERROR (Status); > > ASSERT (mPiPcd != NULL); > > } > > @@ -68,7 +72,11 @@ GetPcdProtocol ( > // PCD protocol need to be installed before the module access Dynamic type PCD. > > // But dynamic type PCD is not required in PI 1.2 specification. > > // > > - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > + Status = gBS->LocateProtocol (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); > > + } else { > > + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); > > + } > > ASSERT_EFI_ERROR (Status); > > ASSERT (mPcd != NULL); > > } > > @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( > EFI_STATUS Status; > > > > if (mPiPcdInfo == NULL) { > > - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > + } else{ > > + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > + } > > ASSERT_EFI_ERROR (Status); > > ASSERT (mPiPcdInfo != NULL); > > } > > @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( > EFI_STATUS Status; > > > > if (mPcdInfo == NULL) { > > - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > + Status = gBS->LocateProtocol (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > + } else { > > + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > + } > > ASSERT_EFI_ERROR (Status); > > ASSERT (mPcdInfo != NULL); > > } > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > index 3d4d21b442..59d9fe4f11 100644 > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > @@ -53,10 +53,18 @@ > > > > > [Protocols] > > - gPcdProtocolGuid ## SOMETIMES_CONSUMES > > - gEfiPcdProtocolGuid ## CONSUMES > > - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + > > + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + > > +[FeaturePcd] > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > > > [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] > > gEfiPcdProtocolGuid > > diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > new file mode 100644 > index 0000000000..e61296e11a > --- /dev/null > +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > @@ -0,0 +1,71 @@ > +## @file > > +# Instance of PCD Library using PCD Protocol. > > +# > > +# There are two PCD protocols as follows: > > +# 1) PCD_PROTOCOL > > +# It is EDKII implementation which support Dynamic/DynamicEx Pcds. > > +# 2) EFI_PCD_PROTOCOL > > +# It is defined by PI specification 1.2, Vol 3 which only support dynamicEx > > +# type Pcd. > > +# > > +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL. > > +# > > +# This library instance uses the PCD_PROTOCOL to handle dynamic PCD request and use > > +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. > > +# > > +# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can only use this DxePcdLib > > +# in their initialization without any issues to access Dynamic and DynamicEx PCD. They can't > > +# access Dynamic and DynamicEx PCD in the implementation of runtime services and SMI handlers. > > +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in OS runtime phase. > > +# > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> > > +# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +# > > +# > > +## > > + > > +[Defines] > > + INF_VERSION = 0x00010005 > > + BASE_NAME = DxePcdLib > > + MODULE_UNI_FILE = DxePcdLib.uni > > + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c > > + MODULE_TYPE = DXE_DRIVER > > + VERSION_STRING = 1.0 > > + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION > UEFI_DRIVER > > + > > +# > > +# VALID_ARCHITECTURES = IA32 X64 EBC > > +# > > + > > +[Sources] > > + DxePcdLib.c > > + > > + > > +[Packages] > > + MdePkg/MdePkg.dec > > + > > + > > +[LibraryClasses] > > + BaseMemoryLib > > + UefiBootServicesTableLib > > + DebugLib > > + > > + > > +[Protocols] > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + > > + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > + > > +[FeaturePcd] > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > + > > +[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid > > + > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index b49f88d8e1..44f60e2086 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -1000,6 +1000,12 @@ > ## Include/Protocol/PcdInfo.h > > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > + ## Payload Standalone Pcd Protocol > > + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, 0x7d, > 0xc9, 0x1f}} > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, 0xae76, 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, 0x04, > 0x4d, 0xea}} > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, 0x14, > 0x5e, 0x15}} > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, 0xa9, > 0x68, 0x9e}} > > + > > # > > # Protocols defined in PI1.0. > > # > > @@ -1945,6 +1951,12 @@ > # @Prompt Validate ORDERED_COLLECTION structure > > gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEAN|0x0000002a > > > > + ## Indicates if the standalone PCD database is enabled for Payload.<BR><BR> > > + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> > > + # FALSE - Disable tandalone PCD database is enabled for Payload.<BR> > > + # @Prompt Enable tandalone PCD database is enabled for Payload. > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOOLEAN|0x0000002e > > + > > [PcdsFixedAtBuild] > > ## Status code value for indicating a watchdog timer has expired. > > # EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_TIMER_EXPIRED > > -- > 2.30.0.windows.2 > > > > -=-=-=-=-=-= > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#75502): https://edk2.groups.io/g/devel/message/75502 > Mute This Topic: https://groups.io/mt/83046935/1643496 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kinney@intel.com] > -=-=-=-=-=-= > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-24 20:29 ` [edk2-devel] " Michael D Kinney @ 2021-05-25 1:09 ` Zhiguang Liu 2021-05-25 14:18 ` Michael D Kinney 2021-05-25 1:33 ` Ni, Ray 1 sibling, 1 reply; 10+ messages in thread From: Zhiguang Liu @ 2021-05-25 1:09 UTC (permalink / raw) To: Kinney, Michael D, devel@edk2.groups.io; +Cc: Liming Gao, Ni, Ray Hi Miki, I want to fix the case where two binaries are built separately, and both want to use PCD feature. For example, bootloader and payload want to have separate PCD data base. Or two payloads both run at DXE phase, and they both need PCD but don't want to other payload to change PCD data. This way, both PCD protocol instance is installed, and different payload will find its own PCD protocol by different GUID. Thanks Zhiguang > -----Original Message----- > From: Kinney, Michael D <michael.d.kinney@intel.com> > Sent: Tuesday, May 25, 2021 4:30 AM > To: devel@edk2.groups.io; Liu, Zhiguang <zhiguang.liu@intel.com>; Kinney, > Michael D <michael.d.kinney@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > Why do we need a new PCD? > > Can't we make this the default behavior to only install one instance? > > Thanks, > > Mike > > > -----Original Message----- > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > > Zhiguang Liu > > Sent: Monday, May 24, 2021 2:25 AM > > To: devel@edk2.groups.io > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao > > <gaoliming@byosoft.com.cn> > > Subject: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > Add a feature PCD to control if the PCD driver is build as standalone mode. > > This way, two mode PCD driver won't share the data base. > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > --- > > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 > +++++++++++++++++++++++++++++++++++++++++++++++++++------------ > ---------- > > -- > > MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- > > MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- > > MdePkg/Include/Protocol/Pcd.h | 5 ----- > > MdePkg/Include/Protocol/PcdInfo.h | 5 ----- > > MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 > ++++++++++++++++++++---- > > MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- > > MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > +++++++++++++ > > MdePkg/MdePkg.dec | 12 ++++++++++++ > > 9 files changed, 184 insertions(+), 47 deletions(-) > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > index cdb9b4fac1..dc9c4be022 100644 > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > @@ -129,34 +129,61 @@ PcdDxeInit ( > > // > > > > // Make sure the Pcd Protocol is not already installed in the > > system > > > > // > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > > + &gEdkiiPayloadStandalonePcdProtocolGuid); > > > > + BuildPcdDxeDataBase (); > > > > > > > > - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > + // > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gEdkiiPayloadStandalonePcdProtocolGuid, &mPcdInstance, > > > > + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, > > + &mEfiPcdInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > - BuildPcdDxeDataBase (); > > > > + // > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, > &mGetPcdInfoInstance, > > > > + > > + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, > > + &mEfiGetPcdInfoInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > + } else { > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > + BuildPcdDxeDataBase (); > > > > > > > > - // > > > > - // Install PCD_PROTOCOL to handle dynamic type PCD > > > > - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > - // > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > - &mPcdHandle, > > > > - &gPcdProtocolGuid, &mPcdInstance, > > > > - &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > - NULL > > > > - ); > > > > - ASSERT_EFI_ERROR (Status); > > > > + // > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gPcdProtocolGuid, &mPcdInstance, > > > > + &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > - // > > > > - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > - // > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > - &mPcdHandle, > > > > - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > - NULL > > > > - ); > > > > - ASSERT_EFI_ERROR (Status); > > > > + // > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > + &gEfiGetPcdInfoProtocolGuid, > > + &mEfiGetPcdInfoInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > + } > > > > > > > > // > > > > // Register callback function upon VariableLockProtocol > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > index eb9f757f14..f3e704f083 100644 > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > @@ -329,10 +329,15 @@ > > gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES > ## GUID > > > > > > > > [Protocols] > > > > - gPcdProtocolGuid ## PRODUCES > > > > - gEfiPcdProtocolGuid ## PRODUCES > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > + gPcdProtocolGuid ## PRODUCES > > > > + gEfiPcdProtocolGuid ## PRODUCES > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > + > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_PRODUCES > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > + SOMETIMES_PRODUCES > > > > ## NOTIFY > > > > ## SOMETIMES_CONSUMES > > > > gEdkiiVariableLockProtocolGuid > > > > @@ -342,6 +347,9 @@ > > gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## > SOMETIMES_CONSUMES > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## > > SOMETIMES_CONSUMES > > > > > > > > +[FeaturePcd] > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > CONSUMES > > > > + > > > > [Depex] > > > > TRUE > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > index ea7edc3cbb..fe16ba713b 100644 > > --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( > > CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb- > >Length); > > > > mPcdDatabase.DxeDb = PcdDxeDb; > > > > > > > > - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + GuidHob = NULL; > > > > + } else { > > > > + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > + } > > > > + > > > > if (GuidHob != NULL) { > > > > > > > > // > > > > diff --git a/MdePkg/Include/Protocol/Pcd.h > > b/MdePkg/Include/Protocol/Pcd.h index 9cd1a998f8..cfa6ac2360 100644 > > --- a/MdePkg/Include/Protocol/Pcd.h > > +++ b/MdePkg/Include/Protocol/Pcd.h > > @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #ifndef __PCD_H__ > > > > #define __PCD_H__ > > > > > > > > -extern EFI_GUID gPcdProtocolGuid; > > > > - > > > > -#define PCD_PROTOCOL_GUID \ > > > > - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, > > 0xe, 0xf7 } } > > > > - > > > > #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) > > > > > > > > > > > > diff --git a/MdePkg/Include/Protocol/PcdInfo.h > > b/MdePkg/Include/Protocol/PcdInfo.h > > index b0ec7f6770..5691215c42 100644 > > --- a/MdePkg/Include/Protocol/PcdInfo.h > > +++ b/MdePkg/Include/Protocol/PcdInfo.h > > @@ -19,11 +19,6 @@ > > #ifndef __PCD_INFO_H__ > > > > #define __PCD_INFO_H__ > > > > > > > > -extern EFI_GUID gGetPcdInfoProtocolGuid; > > > > - > > > > -#define GET_PCD_INFO_PROTOCOL_GUID \ > > > > - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, > > 0xd3, 0x65 } } > > > > - > > > > /// > > > > /// The forward declaration for GET_PCD_INFO_PROTOCOL. > > > > /// > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > index 2accaeda2c..8a61486832 100644 > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > @@ -43,7 +43,11 @@ GetPiPcdProtocol ( > > // PI Pcd protocol defined in PI 1.2 vol3 should be installed > > before the module > > > > // access DynamicEx type PCD. > > > > // > > > > - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) > &mPiPcd); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol > > + (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) > > + &mPiPcd); > > > > + } else { > > > > + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID > > + **) &mPiPcd); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPiPcd != NULL); > > > > } > > > > @@ -68,7 +72,11 @@ GetPcdProtocol ( > > // PCD protocol need to be installed before the module access Dynamic > type PCD. > > > > // But dynamic type PCD is not required in PI 1.2 specification. > > > > // > > > > - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > **)&mPcd); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol > > + (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > + } else { > > > > + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > > + **)&mPcd); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPcd != NULL); > > > > } > > > > @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( > > EFI_STATUS Status; > > > > > > > > if (mPiPcdInfo == NULL) { > > > > - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, > (VOID **)&mPiPcdInfo); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol > > + (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > > + **)&mPiPcdInfo); > > > > + } else{ > > > > + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, > > + NULL, (VOID **)&mPiPcdInfo); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPiPcdInfo != NULL); > > > > } > > > > @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( > > EFI_STATUS Status; > > > > > > > > if (mPcdInfo == NULL) { > > > > - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID > **)&mPcdInfo); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol > > + (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > > + **)&mPcdInfo); > > > > + } else { > > > > + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, > > + (VOID **)&mPcdInfo); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPcdInfo != NULL); > > > > } > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > index 3d4d21b442..59d9fe4f11 100644 > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > @@ -53,10 +53,18 @@ > > > > > > > > > > [Protocols] > > > > - gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > - gEfiPcdProtocolGuid ## CONSUMES > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > + SOMETIMES_CONSUMES > > > > + > > > > +[FeaturePcd] > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > CONSUMES > > > > > > > > [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, > > Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] > > > > gEfiPcdProtocolGuid > > > > diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > new file mode 100644 > > index 0000000000..e61296e11a > > --- /dev/null > > +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > @@ -0,0 +1,71 @@ > > +## @file > > > > +# Instance of PCD Library using PCD Protocol. > > > > +# > > > > +# There are two PCD protocols as follows: > > > > +# 1) PCD_PROTOCOL > > > > +# It is EDKII implementation which support Dynamic/DynamicEx Pcds. > > > > +# 2) EFI_PCD_PROTOCOL > > > > +# It is defined by PI specification 1.2, Vol 3 which only support > dynamicEx > > > > +# type Pcd. > > > > +# > > > > +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and > EFI_PCD_PROTOCOL. > > > > +# > > > > +# This library instance uses the PCD_PROTOCOL to handle dynamic PCD > > +request and use > > > > +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. > > > > +# > > > > +# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER > can > > +only use this DxePcdLib > > > > +# in their initialization without any issues to access Dynamic and > > +DynamicEx PCD. They can't > > > > +# access Dynamic and DynamicEx PCD in the implementation of runtime > services and SMI handlers. > > > > +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in OS > runtime phase. > > > > +# > > > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights > > +reserved.<BR> > > > > +# > > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > > +# > > > > +# > > > > +## > > > > + > > > > +[Defines] > > > > + INF_VERSION = 0x00010005 > > > > + BASE_NAME = DxePcdLib > > > > + MODULE_UNI_FILE = DxePcdLib.uni > > > > + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c > > > > + MODULE_TYPE = DXE_DRIVER > > > > + VERSION_STRING = 1.0 > > > > + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER > DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION > > UEFI_DRIVER > > > > + > > > > +# > > > > +# VALID_ARCHITECTURES = IA32 X64 EBC > > > > +# > > > > + > > > > +[Sources] > > > > + DxePcdLib.c > > > > + > > > > + > > > > +[Packages] > > > > + MdePkg/MdePkg.dec > > > > + > > > > + > > > > +[LibraryClasses] > > > > + BaseMemoryLib > > > > + UefiBootServicesTableLib > > > > + DebugLib > > > > + > > > > + > > > > +[Protocols] > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > + SOMETIMES_CONSUMES > > > > + > > > > +[FeaturePcd] > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > CONSUMES > > > > + > > > > +[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, > > +Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid > > > > + > > > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index > > b49f88d8e1..44f60e2086 100644 > > --- a/MdePkg/MdePkg.dec > > +++ b/MdePkg/MdePkg.dec > > @@ -1000,6 +1000,12 @@ > > ## Include/Protocol/PcdInfo.h > > > > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, > 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > > > > > + ## Payload Standalone Pcd Protocol > > > > + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, > 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, 0x7d, > > 0xc9, 0x1f}} > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, 0xae76, > 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, 0x04, > > 0x4d, 0xea}} > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, > 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, 0x14, > > 0x5e, 0x15}} > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, > > + 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, 0xa9, > > 0x68, 0x9e}} > > > > + > > > > # > > > > # Protocols defined in PI1.0. > > > > # > > > > @@ -1945,6 +1951,12 @@ > > # @Prompt Validate ORDERED_COLLECTION structure > > > > > > > gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEA > N|0x > > 0000002a > > > > > > > > + ## Indicates if the standalone PCD database is enabled for > > + Payload.<BR><BR> > > > > + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> > > > > + # FALSE - Disable tandalone PCD database is enabled for Payload.<BR> > > > > + # @Prompt Enable tandalone PCD database is enabled for Payload. > > > > + > > + > gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOO > LEA > > + N|0x0000002e > > > > + > > > > [PcdsFixedAtBuild] > > > > ## Status code value for indicating a watchdog timer has expired. > > > > # EFI_COMPUTING_UNIT_HOST_PROCESSOR | > EFI_CU_HP_EC_TIMER_EXPIRED > > > > -- > > 2.30.0.windows.2 > > > > > > > > -=-=-=-=-=-= > > Groups.io Links: You receive all messages sent to this group. > > View/Reply Online (#75502): > > https://edk2.groups.io/g/devel/message/75502 > > Mute This Topic: https://groups.io/mt/83046935/1643496 > > Group Owner: devel+owner@edk2.groups.io > > Unsubscribe: https://edk2.groups.io/g/devel/unsub > > [michael.d.kinney@intel.com] -=-=-=-=-=-= > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-25 1:09 ` Zhiguang Liu @ 2021-05-25 14:18 ` Michael D Kinney 0 siblings, 0 replies; 10+ messages in thread From: Michael D Kinney @ 2021-05-25 14:18 UTC (permalink / raw) To: Liu, Zhiguang, devel@edk2.groups.io, Kinney, Michael D Cc: Liming Gao, Ni, Ray What does different PCD Database with a different GUID mean? Has the problem statement and design for multiple PCD databases from multiple binaries been reviewed in the TianoCore design meeting? This sounds like a topic that needs more discussion before making changes like this. Thanks, Mike > -----Original Message----- > From: Liu, Zhiguang <zhiguang.liu@intel.com> > Sent: Monday, May 24, 2021 6:10 PM > To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io > Cc: Liming Gao <gaoliming@byosoft.com.cn>; Ni, Ray <ray.ni@intel.com> > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > Hi Miki, > > I want to fix the case where two binaries are built separately, and both want to use PCD feature. > For example, bootloader and payload want to have separate PCD data base. > Or two payloads both run at DXE phase, and they both need PCD but don't want to other payload to change PCD data. > This way, both PCD protocol instance is installed, and different payload will find its own PCD protocol by different GUID. > > Thanks > Zhiguang > > > -----Original Message----- > > From: Kinney, Michael D <michael.d.kinney@intel.com> > > Sent: Tuesday, May 25, 2021 4:30 AM > > To: devel@edk2.groups.io; Liu, Zhiguang <zhiguang.liu@intel.com>; Kinney, > > Michael D <michael.d.kinney@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > Why do we need a new PCD? > > > > Can't we make this the default behavior to only install one instance? > > > > Thanks, > > > > Mike > > > > > -----Original Message----- > > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > > > Zhiguang Liu > > > Sent: Monday, May 24, 2021 2:25 AM > > > To: devel@edk2.groups.io > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao > > > <gaoliming@byosoft.com.cn> > > > Subject: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > > > Add a feature PCD to control if the PCD driver is build as standalone mode. > > > This way, two mode PCD driver won't share the data base. > > > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > > --- > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 > > +++++++++++++++++++++++++++++++++++++++++++++++++++------------ > > ---------- > > > -- > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- > > > MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- > > > MdePkg/Include/Protocol/Pcd.h | 5 ----- > > > MdePkg/Include/Protocol/PcdInfo.h | 5 ----- > > > MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 > > ++++++++++++++++++++---- > > > MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- > > > MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > +++++++++++++ > > > MdePkg/MdePkg.dec | 12 ++++++++++++ > > > 9 files changed, 184 insertions(+), 47 deletions(-) > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > index cdb9b4fac1..dc9c4be022 100644 > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > @@ -129,34 +129,61 @@ PcdDxeInit ( > > > // > > > > > > // Make sure the Pcd Protocol is not already installed in the > > > system > > > > > > // > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > > > + &gEdkiiPayloadStandalonePcdProtocolGuid); > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > > > + // > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gEdkiiPayloadStandalonePcdProtocolGuid, &mPcdInstance, > > > > > > + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, > > > + &mEfiPcdInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > - BuildPcdDxeDataBase (); > > > > > > + // > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, > > &mGetPcdInfoInstance, > > > > > > + > > > + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, > > > + &mEfiGetPcdInfoInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > + } else { > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > - // > > > > > > - // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > - // > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > - &mPcdHandle, > > > > > > - &gPcdProtocolGuid, &mPcdInstance, > > > > > > - &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > - NULL > > > > > > - ); > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > + // > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gPcdProtocolGuid, &mPcdInstance, > > > > > > + &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > - // > > > > > > - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > > > - // > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > - &mPcdHandle, > > > > > > - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > - NULL > > > > > > - ); > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > + // > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > + &gEfiGetPcdInfoProtocolGuid, > > > + &mEfiGetPcdInfoInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > + } > > > > > > > > > > > > // > > > > > > // Register callback function upon VariableLockProtocol > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > index eb9f757f14..f3e704f083 100644 > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > @@ -329,10 +329,15 @@ > > > gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES > > ## GUID > > > > > > > > > > > > [Protocols] > > > > > > - gPcdProtocolGuid ## PRODUCES > > > > > > - gEfiPcdProtocolGuid ## PRODUCES > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > + gPcdProtocolGuid ## PRODUCES > > > > > > + gEfiPcdProtocolGuid ## PRODUCES > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > + > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_PRODUCES > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > > + SOMETIMES_PRODUCES > > > > > > ## NOTIFY > > > > > > ## SOMETIMES_CONSUMES > > > > > > gEdkiiVariableLockProtocolGuid > > > > > > @@ -342,6 +347,9 @@ > > > gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## > > SOMETIMES_CONSUMES > > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## > > > SOMETIMES_CONSUMES > > > > > > > > > > > > +[FeaturePcd] > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > > CONSUMES > > > > > > + > > > > > > [Depex] > > > > > > TRUE > > > > > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > index ea7edc3cbb..fe16ba713b 100644 > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( > > > CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb- > > >Length); > > > > > > mPcdDatabase.DxeDb = PcdDxeDb; > > > > > > > > > > > > - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + GuidHob = NULL; > > > > > > + } else { > > > > > > + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > + } > > > > > > + > > > > > > if (GuidHob != NULL) { > > > > > > > > > > > > // > > > > > > diff --git a/MdePkg/Include/Protocol/Pcd.h > > > b/MdePkg/Include/Protocol/Pcd.h index 9cd1a998f8..cfa6ac2360 100644 > > > --- a/MdePkg/Include/Protocol/Pcd.h > > > +++ b/MdePkg/Include/Protocol/Pcd.h > > > @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > #ifndef __PCD_H__ > > > > > > #define __PCD_H__ > > > > > > > > > > > > -extern EFI_GUID gPcdProtocolGuid; > > > > > > - > > > > > > -#define PCD_PROTOCOL_GUID \ > > > > > > - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, > > > 0xe, 0xf7 } } > > > > > > - > > > > > > #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) > > > > > > > > > > > > > > > > > > diff --git a/MdePkg/Include/Protocol/PcdInfo.h > > > b/MdePkg/Include/Protocol/PcdInfo.h > > > index b0ec7f6770..5691215c42 100644 > > > --- a/MdePkg/Include/Protocol/PcdInfo.h > > > +++ b/MdePkg/Include/Protocol/PcdInfo.h > > > @@ -19,11 +19,6 @@ > > > #ifndef __PCD_INFO_H__ > > > > > > #define __PCD_INFO_H__ > > > > > > > > > > > > -extern EFI_GUID gGetPcdInfoProtocolGuid; > > > > > > - > > > > > > -#define GET_PCD_INFO_PROTOCOL_GUID \ > > > > > > - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, > > > 0xd3, 0x65 } } > > > > > > - > > > > > > /// > > > > > > /// The forward declaration for GET_PCD_INFO_PROTOCOL. > > > > > > /// > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > index 2accaeda2c..8a61486832 100644 > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > @@ -43,7 +43,11 @@ GetPiPcdProtocol ( > > > // PI Pcd protocol defined in PI 1.2 vol3 should be installed > > > before the module > > > > > > // access DynamicEx type PCD. > > > > > > // > > > > > > - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) > > &mPiPcd); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol > > > + (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) > > > + &mPiPcd); > > > > > > + } else { > > > > > > + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID > > > + **) &mPiPcd); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPiPcd != NULL); > > > > > > } > > > > > > @@ -68,7 +72,11 @@ GetPcdProtocol ( > > > // PCD protocol need to be installed before the module access Dynamic > > type PCD. > > > > > > // But dynamic type PCD is not required in PI 1.2 specification. > > > > > > // > > > > > > - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > > **)&mPcd); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol > > > + (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > > > + } else { > > > > > > + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > > > + **)&mPcd); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPcd != NULL); > > > > > > } > > > > > > @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( > > > EFI_STATUS Status; > > > > > > > > > > > > if (mPiPcdInfo == NULL) { > > > > > > - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, > > (VOID **)&mPiPcdInfo); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol > > > + (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > > > + **)&mPiPcdInfo); > > > > > > + } else{ > > > > > > + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, > > > + NULL, (VOID **)&mPiPcdInfo); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPiPcdInfo != NULL); > > > > > > } > > > > > > @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( > > > EFI_STATUS Status; > > > > > > > > > > > > if (mPcdInfo == NULL) { > > > > > > - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID > > **)&mPcdInfo); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol > > > + (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > > > + **)&mPcdInfo); > > > > > > + } else { > > > > > > + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, > > > + (VOID **)&mPcdInfo); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPcdInfo != NULL); > > > > > > } > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > index 3d4d21b442..59d9fe4f11 100644 > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > @@ -53,10 +53,18 @@ > > > > > > > > > > > > > > > [Protocols] > > > > > > - gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > - gEfiPcdProtocolGuid ## CONSUMES > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > > + SOMETIMES_CONSUMES > > > > > > + > > > > > > +[FeaturePcd] > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > > CONSUMES > > > > > > > > > > > > [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, > > > Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] > > > > > > gEfiPcdProtocolGuid > > > > > > diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > new file mode 100644 > > > index 0000000000..e61296e11a > > > --- /dev/null > > > +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > @@ -0,0 +1,71 @@ > > > +## @file > > > > > > +# Instance of PCD Library using PCD Protocol. > > > > > > +# > > > > > > +# There are two PCD protocols as follows: > > > > > > +# 1) PCD_PROTOCOL > > > > > > +# It is EDKII implementation which support Dynamic/DynamicEx Pcds. > > > > > > +# 2) EFI_PCD_PROTOCOL > > > > > > +# It is defined by PI specification 1.2, Vol 3 which only support > > dynamicEx > > > > > > +# type Pcd. > > > > > > +# > > > > > > +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and > > EFI_PCD_PROTOCOL. > > > > > > +# > > > > > > +# This library instance uses the PCD_PROTOCOL to handle dynamic PCD > > > +request and use > > > > > > +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. > > > > > > +# > > > > > > +# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER > > can > > > +only use this DxePcdLib > > > > > > +# in their initialization without any issues to access Dynamic and > > > +DynamicEx PCD. They can't > > > > > > +# access Dynamic and DynamicEx PCD in the implementation of runtime > > services and SMI handlers. > > > > > > +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in OS > > runtime phase. > > > > > > +# > > > > > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights > > > +reserved.<BR> > > > > > > +# > > > > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > +# > > > > > > +# > > > > > > +## > > > > > > + > > > > > > +[Defines] > > > > > > + INF_VERSION = 0x00010005 > > > > > > + BASE_NAME = DxePcdLib > > > > > > + MODULE_UNI_FILE = DxePcdLib.uni > > > > > > + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c > > > > > > + MODULE_TYPE = DXE_DRIVER > > > > > > + VERSION_STRING = 1.0 > > > > > > + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER > > DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION > > > UEFI_DRIVER > > > > > > + > > > > > > +# > > > > > > +# VALID_ARCHITECTURES = IA32 X64 EBC > > > > > > +# > > > > > > + > > > > > > +[Sources] > > > > > > + DxePcdLib.c > > > > > > + > > > > > > + > > > > > > +[Packages] > > > > > > + MdePkg/MdePkg.dec > > > > > > + > > > > > > + > > > > > > +[LibraryClasses] > > > > > > + BaseMemoryLib > > > > > > + UefiBootServicesTableLib > > > > > > + DebugLib > > > > > > + > > > > > > + > > > > > > +[Protocols] > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > > + SOMETIMES_CONSUMES > > > > > > + > > > > > > +[FeaturePcd] > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > > CONSUMES > > > > > > + > > > > > > +[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, > > > +Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid > > > > > > + > > > > > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index > > > b49f88d8e1..44f60e2086 100644 > > > --- a/MdePkg/MdePkg.dec > > > +++ b/MdePkg/MdePkg.dec > > > @@ -1000,6 +1000,12 @@ > > > ## Include/Protocol/PcdInfo.h > > > > > > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, > > 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > > > > > > > > > + ## Payload Standalone Pcd Protocol > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, > > 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, 0x7d, > > > 0xc9, 0x1f}} > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, 0xae76, > > 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, 0x04, > > > 0x4d, 0xea}} > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, > > 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, 0x14, > > > 0x5e, 0x15}} > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, > > > + 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, 0xa9, > > > 0x68, 0x9e}} > > > > > > + > > > > > > # > > > > > > # Protocols defined in PI1.0. > > > > > > # > > > > > > @@ -1945,6 +1951,12 @@ > > > # @Prompt Validate ORDERED_COLLECTION structure > > > > > > > > > > > gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEA > > N|0x > > > 0000002a > > > > > > > > > > > > + ## Indicates if the standalone PCD database is enabled for > > > + Payload.<BR><BR> > > > > > > + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> > > > > > > + # FALSE - Disable tandalone PCD database is enabled for Payload.<BR> > > > > > > + # @Prompt Enable tandalone PCD database is enabled for Payload. > > > > > > + > > > + > > gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOO > > LEA > > > + N|0x0000002e > > > > > > + > > > > > > [PcdsFixedAtBuild] > > > > > > ## Status code value for indicating a watchdog timer has expired. > > > > > > # EFI_COMPUTING_UNIT_HOST_PROCESSOR | > > EFI_CU_HP_EC_TIMER_EXPIRED > > > > > > -- > > > 2.30.0.windows.2 > > > > > > > > > > > > -=-=-=-=-=-= > > > Groups.io Links: You receive all messages sent to this group. > > > View/Reply Online (#75502): > > > https://edk2.groups.io/g/devel/message/75502 > > > Mute This Topic: https://groups.io/mt/83046935/1643496 > > > Group Owner: devel+owner@edk2.groups.io > > > Unsubscribe: https://edk2.groups.io/g/devel/unsub > > > [michael.d.kinney@intel.com] -=-=-=-=-=-= > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-24 20:29 ` [edk2-devel] " Michael D Kinney 2021-05-25 1:09 ` Zhiguang Liu @ 2021-05-25 1:33 ` Ni, Ray 2021-05-25 14:35 ` Michael D Kinney 1 sibling, 1 reply; 10+ messages in thread From: Ni, Ray @ 2021-05-25 1:33 UTC (permalink / raw) To: devel@edk2.groups.io, Kinney, Michael D, Liu, Zhiguang; +Cc: Liming Gao Mike, In payload phase, there are two kinds of payloads: 1. the universal payloads that conform to universal payload spec. These payloads cannot depend on any PCD produced from bootloader phase. 2. the platform payloads. These payloads are developed by the same vendor as the bootloader. So, they can depend on the PCD produced by the bootloader. The ultimate goal is these platform payloads can be eliminated. Thanks, Ray > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D Kinney > Sent: Tuesday, May 25, 2021 4:30 AM > To: devel@edk2.groups.io; Liu, Zhiguang <zhiguang.liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Subject: Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > Why do we need a new PCD? > > Can't we make this the default behavior to only install one instance? > > Thanks, > > Mike > > > -----Original Message----- > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Zhiguang Liu > > Sent: Monday, May 24, 2021 2:25 AM > > To: devel@edk2.groups.io > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn> > > Subject: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > Add a feature PCD to control if the PCD driver is build as standalone mode. > > This way, two mode PCD driver won't share the data base. > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > --- > > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++--------------- > ------- > > -- > > MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- > > MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- > > MdePkg/Include/Protocol/Pcd.h | 5 ----- > > MdePkg/Include/Protocol/PcdInfo.h | 5 ----- > > MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 ++++++++++++++++++++---- > > MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- > > MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > MdePkg/MdePkg.dec | 12 ++++++++++++ > > 9 files changed, 184 insertions(+), 47 deletions(-) > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > index cdb9b4fac1..dc9c4be022 100644 > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > @@ -129,34 +129,61 @@ PcdDxeInit ( > > // > > > > // Make sure the Pcd Protocol is not already installed in the system > > > > // > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEdkiiPayloadStandalonePcdProtocolGuid); > > > > + BuildPcdDxeDataBase (); > > > > > > > > - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > + // > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gEdkiiPayloadStandalonePcdProtocolGuid, &mPcdInstance, > > > > + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, &mEfiPcdInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > - BuildPcdDxeDataBase (); > > > > + // > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > + } else { > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > + BuildPcdDxeDataBase (); > > > > > > > > - // > > > > - // Install PCD_PROTOCOL to handle dynamic type PCD > > > > - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > - // > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > - &mPcdHandle, > > > > - &gPcdProtocolGuid, &mPcdInstance, > > > > - &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > - NULL > > > > - ); > > > > - ASSERT_EFI_ERROR (Status); > > > > + // > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gPcdProtocolGuid, &mPcdInstance, > > > > + &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > - // > > > > - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > - // > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > - &mPcdHandle, > > > > - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > - NULL > > > > - ); > > > > - ASSERT_EFI_ERROR (Status); > > > > + // > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > + // > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > + &mPcdHandle, > > > > + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > + &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > + NULL > > > > + ); > > > > + ASSERT_EFI_ERROR (Status); > > > > + } > > > > > > > > // > > > > // Register callback function upon VariableLockProtocol > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > index eb9f757f14..f3e704f083 100644 > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > @@ -329,10 +329,15 @@ > > gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES ## GUID > > > > > > > > [Protocols] > > > > - gPcdProtocolGuid ## PRODUCES > > > > - gEfiPcdProtocolGuid ## PRODUCES > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > + gPcdProtocolGuid ## PRODUCES > > > > + gEfiPcdProtocolGuid ## PRODUCES > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > + > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > ## NOTIFY > > > > ## SOMETIMES_CONSUMES > > > > gEdkiiVariableLockProtocolGuid > > > > @@ -342,6 +347,9 @@ > > gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## SOMETIMES_CONSUMES > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## SOMETIMES_CONSUMES > > > > > > > > +[FeaturePcd] > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > > > + > > > > [Depex] > > > > TRUE > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > index ea7edc3cbb..fe16ba713b 100644 > > --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( > > CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length); > > > > mPcdDatabase.DxeDb = PcdDxeDb; > > > > > > > > - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + GuidHob = NULL; > > > > + } else { > > > > + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > + } > > > > + > > > > if (GuidHob != NULL) { > > > > > > > > // > > > > diff --git a/MdePkg/Include/Protocol/Pcd.h b/MdePkg/Include/Protocol/Pcd.h > > index 9cd1a998f8..cfa6ac2360 100644 > > --- a/MdePkg/Include/Protocol/Pcd.h > > +++ b/MdePkg/Include/Protocol/Pcd.h > > @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #ifndef __PCD_H__ > > > > #define __PCD_H__ > > > > > > > > -extern EFI_GUID gPcdProtocolGuid; > > > > - > > > > -#define PCD_PROTOCOL_GUID \ > > > > - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, 0xe, 0xf7 } } > > > > - > > > > #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) > > > > > > > > > > > > diff --git a/MdePkg/Include/Protocol/PcdInfo.h b/MdePkg/Include/Protocol/PcdInfo.h > > index b0ec7f6770..5691215c42 100644 > > --- a/MdePkg/Include/Protocol/PcdInfo.h > > +++ b/MdePkg/Include/Protocol/PcdInfo.h > > @@ -19,11 +19,6 @@ > > #ifndef __PCD_INFO_H__ > > > > #define __PCD_INFO_H__ > > > > > > > > -extern EFI_GUID gGetPcdInfoProtocolGuid; > > > > - > > > > -#define GET_PCD_INFO_PROTOCOL_GUID \ > > > > - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > - > > > > /// > > > > /// The forward declaration for GET_PCD_INFO_PROTOCOL. > > > > /// > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > index 2accaeda2c..8a61486832 100644 > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > @@ -43,7 +43,11 @@ GetPiPcdProtocol ( > > // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module > > > > // access DynamicEx type PCD. > > > > // > > > > - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > + } else { > > > > + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPiPcd != NULL); > > > > } > > > > @@ -68,7 +72,11 @@ GetPcdProtocol ( > > // PCD protocol need to be installed before the module access Dynamic type PCD. > > > > // But dynamic type PCD is not required in PI 1.2 specification. > > > > // > > > > - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > + } else { > > > > + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPcd != NULL); > > > > } > > > > @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( > > EFI_STATUS Status; > > > > > > > > if (mPiPcdInfo == NULL) { > > > > - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > > > + } else{ > > > > + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPiPcdInfo != NULL); > > > > } > > > > @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( > > EFI_STATUS Status; > > > > > > > > if (mPcdInfo == NULL) { > > > > - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > + Status = gBS->LocateProtocol (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > > > + } else { > > > > + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > > > + } > > > > ASSERT_EFI_ERROR (Status); > > > > ASSERT (mPcdInfo != NULL); > > > > } > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > index 3d4d21b442..59d9fe4f11 100644 > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > @@ -53,10 +53,18 @@ > > > > > > > > > > [Protocols] > > > > - gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > - gEfiPcdProtocolGuid ## CONSUMES > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + > > > > +[FeaturePcd] > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > > > > > > > [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > Depex.common.DXE_SMM_DRIVER] > > > > gEfiPcdProtocolGuid > > > > diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > new file mode 100644 > > index 0000000000..e61296e11a > > --- /dev/null > > +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > @@ -0,0 +1,71 @@ > > +## @file > > > > +# Instance of PCD Library using PCD Protocol. > > > > +# > > > > +# There are two PCD protocols as follows: > > > > +# 1) PCD_PROTOCOL > > > > +# It is EDKII implementation which support Dynamic/DynamicEx Pcds. > > > > +# 2) EFI_PCD_PROTOCOL > > > > +# It is defined by PI specification 1.2, Vol 3 which only support dynamicEx > > > > +# type Pcd. > > > > +# > > > > +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL. > > > > +# > > > > +# This library instance uses the PCD_PROTOCOL to handle dynamic PCD request and use > > > > +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. > > > > +# > > > > +# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can only use this DxePcdLib > > > > +# in their initialization without any issues to access Dynamic and DynamicEx PCD. They can't > > > > +# access Dynamic and DynamicEx PCD in the implementation of runtime services and SMI handlers. > > > > +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in OS runtime phase. > > > > +# > > > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> > > > > +# > > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > > +# > > > > +# > > > > +## > > > > + > > > > +[Defines] > > > > + INF_VERSION = 0x00010005 > > > > + BASE_NAME = DxePcdLib > > > > + MODULE_UNI_FILE = DxePcdLib.uni > > > > + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c > > > > + MODULE_TYPE = DXE_DRIVER > > > > + VERSION_STRING = 1.0 > > > > + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE > UEFI_APPLICATION > > UEFI_DRIVER > > > > + > > > > +# > > > > +# VALID_ARCHITECTURES = IA32 X64 EBC > > > > +# > > > > + > > > > +[Sources] > > > > + DxePcdLib.c > > > > + > > > > + > > > > +[Packages] > > > > + MdePkg/MdePkg.dec > > > > + > > > > + > > > > +[LibraryClasses] > > > > + BaseMemoryLib > > > > + UefiBootServicesTableLib > > > > + DebugLib > > > > + > > > > + > > > > +[Protocols] > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > + > > > > +[FeaturePcd] > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > > > + > > > > +[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > Depex.common.DXE_SMM_DRIVER] > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid > > > > + > > > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > > index b49f88d8e1..44f60e2086 100644 > > --- a/MdePkg/MdePkg.dec > > +++ b/MdePkg/MdePkg.dec > > @@ -1000,6 +1000,12 @@ > > ## Include/Protocol/PcdInfo.h > > > > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > > > > > + ## Payload Standalone Pcd Protocol > > > > + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, 0x7d, > > 0xc9, 0x1f}} > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, 0xae76, 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, 0x04, > > 0x4d, 0xea}} > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, 0x14, > > 0x5e, 0x15}} > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, 0xa9, > > 0x68, 0x9e}} > > > > + > > > > # > > > > # Protocols defined in PI1.0. > > > > # > > > > @@ -1945,6 +1951,12 @@ > > # @Prompt Validate ORDERED_COLLECTION structure > > > > gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEAN|0x0000002a > > > > > > > > + ## Indicates if the standalone PCD database is enabled for Payload.<BR><BR> > > > > + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> > > > > + # FALSE - Disable tandalone PCD database is enabled for Payload.<BR> > > > > + # @Prompt Enable tandalone PCD database is enabled for Payload. > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOOLEAN|0x0000002e > > > > + > > > > [PcdsFixedAtBuild] > > > > ## Status code value for indicating a watchdog timer has expired. > > > > # EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_TIMER_EXPIRED > > > > -- > > 2.30.0.windows.2 > > > > > > > > -=-=-=-=-=-= > > Groups.io Links: You receive all messages sent to this group. > > View/Reply Online (#75502): https://edk2.groups.io/g/devel/message/75502 > > Mute This Topic: https://groups.io/mt/83046935/1643496 > > Group Owner: devel+owner@edk2.groups.io > > Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kinney@intel.com] > > -=-=-=-=-=-= > > > > > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-25 1:33 ` Ni, Ray @ 2021-05-25 14:35 ` Michael D Kinney 2021-05-26 2:03 ` Ni, Ray 0 siblings, 1 reply; 10+ messages in thread From: Michael D Kinney @ 2021-05-25 14:35 UTC (permalink / raw) To: Ni, Ray, devel@edk2.groups.io, Liu, Zhiguang, Kinney, Michael D Cc: Liming Gao Hi Ray, The PCD Database is intended to be owned by the platform FW. The concept of a universal payload that is loaded after the platform FW is similar in concept to loading a UEFI app/driver/osloader. Those types of loadable UEFI components are not allowed to use the PCD services The only time the PCD PPI/Protocol are accessed is if the PCD type is Dynamic or DynamicEx. Why do components in the Universal Payload need to access PCDs of type Dynamic or DynamicEx? Can we restrict components in the Universal Payload to only use PCDs of type FeatureFlag/FixedAtBuild/PatchableInModule? Thanks, Mike > -----Original Message----- > From: Ni, Ray <ray.ni@intel.com> > Sent: Monday, May 24, 2021 6:33 PM > To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > Mike, > In payload phase, there are two kinds of payloads: > 1. the universal payloads that conform to universal payload spec. These payloads cannot depend on any PCD produced from > bootloader phase. > 2. the platform payloads. These payloads are developed by the same vendor as the bootloader. So, they can depend on the > PCD produced by the bootloader. The ultimate goal is these platform payloads can be eliminated. > > Thanks, > Ray > > > -----Original Message----- > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D Kinney > > Sent: Tuesday, May 25, 2021 4:30 AM > > To: devel@edk2.groups.io; Liu, Zhiguang <zhiguang.liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Subject: Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > Why do we need a new PCD? > > > > Can't we make this the default behavior to only install one instance? > > > > Thanks, > > > > Mike > > > > > -----Original Message----- > > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Zhiguang Liu > > > Sent: Monday, May 24, 2021 2:25 AM > > > To: devel@edk2.groups.io > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn> > > > Subject: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > > > Add a feature PCD to control if the PCD driver is build as standalone mode. > > > This way, two mode PCD driver won't share the data base. > > > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > > --- > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++--------------- > > ------- > > > -- > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- > > > MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- > > > MdePkg/Include/Protocol/Pcd.h | 5 ----- > > > MdePkg/Include/Protocol/PcdInfo.h | 5 ----- > > > MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 ++++++++++++++++++++---- > > > MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- > > > MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > MdePkg/MdePkg.dec | 12 ++++++++++++ > > > 9 files changed, 184 insertions(+), 47 deletions(-) > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > index cdb9b4fac1..dc9c4be022 100644 > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > @@ -129,34 +129,61 @@ PcdDxeInit ( > > > // > > > > > > // Make sure the Pcd Protocol is not already installed in the system > > > > > > // > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEdkiiPayloadStandalonePcdProtocolGuid); > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > > > + // > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gEdkiiPayloadStandalonePcdProtocolGuid, &mPcdInstance, > > > > > > + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, &mEfiPcdInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > - BuildPcdDxeDataBase (); > > > > > > + // > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > + } else { > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid); > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > - // > > > > > > - // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > - // > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > - &mPcdHandle, > > > > > > - &gPcdProtocolGuid, &mPcdInstance, > > > > > > - &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > - NULL > > > > > > - ); > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > + // > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gPcdProtocolGuid, &mPcdInstance, > > > > > > + &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > - // > > > > > > - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > > > - // > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > - &mPcdHandle, > > > > > > - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > - NULL > > > > > > - ); > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > + // > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD > > > > > > + // > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > + &mPcdHandle, > > > > > > + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > + &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > + NULL > > > > > > + ); > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > + } > > > > > > > > > > > > // > > > > > > // Register callback function upon VariableLockProtocol > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > index eb9f757f14..f3e704f083 100644 > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > @@ -329,10 +329,15 @@ > > > gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES ## GUID > > > > > > > > > > > > [Protocols] > > > > > > - gPcdProtocolGuid ## PRODUCES > > > > > > - gEfiPcdProtocolGuid ## PRODUCES > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > + gPcdProtocolGuid ## PRODUCES > > > > > > + gEfiPcdProtocolGuid ## PRODUCES > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > + > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > ## NOTIFY > > > > > > ## SOMETIMES_CONSUMES > > > > > > gEdkiiVariableLockProtocolGuid > > > > > > @@ -342,6 +347,9 @@ > > > gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## SOMETIMES_CONSUMES > > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## SOMETIMES_CONSUMES > > > > > > > > > > > > +[FeaturePcd] > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > > > > > + > > > > > > [Depex] > > > > > > TRUE > > > > > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > index ea7edc3cbb..fe16ba713b 100644 > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( > > > CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length); > > > > > > mPcdDatabase.DxeDb = PcdDxeDb; > > > > > > > > > > > > - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + GuidHob = NULL; > > > > > > + } else { > > > > > > + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > + } > > > > > > + > > > > > > if (GuidHob != NULL) { > > > > > > > > > > > > // > > > > > > diff --git a/MdePkg/Include/Protocol/Pcd.h b/MdePkg/Include/Protocol/Pcd.h > > > index 9cd1a998f8..cfa6ac2360 100644 > > > --- a/MdePkg/Include/Protocol/Pcd.h > > > +++ b/MdePkg/Include/Protocol/Pcd.h > > > @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > #ifndef __PCD_H__ > > > > > > #define __PCD_H__ > > > > > > > > > > > > -extern EFI_GUID gPcdProtocolGuid; > > > > > > - > > > > > > -#define PCD_PROTOCOL_GUID \ > > > > > > - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, 0xe, 0xf7 } } > > > > > > - > > > > > > #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) > > > > > > > > > > > > > > > > > > diff --git a/MdePkg/Include/Protocol/PcdInfo.h b/MdePkg/Include/Protocol/PcdInfo.h > > > index b0ec7f6770..5691215c42 100644 > > > --- a/MdePkg/Include/Protocol/PcdInfo.h > > > +++ b/MdePkg/Include/Protocol/PcdInfo.h > > > @@ -19,11 +19,6 @@ > > > #ifndef __PCD_INFO_H__ > > > > > > #define __PCD_INFO_H__ > > > > > > > > > > > > -extern EFI_GUID gGetPcdInfoProtocolGuid; > > > > > > - > > > > > > -#define GET_PCD_INFO_PROTOCOL_GUID \ > > > > > > - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > > > - > > > > > > /// > > > > > > /// The forward declaration for GET_PCD_INFO_PROTOCOL. > > > > > > /// > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > index 2accaeda2c..8a61486832 100644 > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > @@ -43,7 +43,11 @@ GetPiPcdProtocol ( > > > // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module > > > > > > // access DynamicEx type PCD. > > > > > > // > > > > > > - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > > > + } else { > > > > > > + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPiPcd != NULL); > > > > > > } > > > > > > @@ -68,7 +72,11 @@ GetPcdProtocol ( > > > // PCD protocol need to be installed before the module access Dynamic type PCD. > > > > > > // But dynamic type PCD is not required in PI 1.2 specification. > > > > > > // > > > > > > - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > > > + } else { > > > > > > + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPcd != NULL); > > > > > > } > > > > > > @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( > > > EFI_STATUS Status; > > > > > > > > > > > > if (mPiPcdInfo == NULL) { > > > > > > - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > > > > > + } else{ > > > > > > + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPiPcdInfo != NULL); > > > > > > } > > > > > > @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( > > > EFI_STATUS Status; > > > > > > > > > > > > if (mPcdInfo == NULL) { > > > > > > - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > + Status = gBS->LocateProtocol (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > > > > > + } else { > > > > > > + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); > > > > > > + } > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > ASSERT (mPcdInfo != NULL); > > > > > > } > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > index 3d4d21b442..59d9fe4f11 100644 > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > @@ -53,10 +53,18 @@ > > > > > > > > > > > > > > > [Protocols] > > > > > > - gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > - gEfiPcdProtocolGuid ## CONSUMES > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + > > > > > > +[FeaturePcd] > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > > > > > > > > > > > [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > > Depex.common.DXE_SMM_DRIVER] > > > > > > gEfiPcdProtocolGuid > > > > > > diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > new file mode 100644 > > > index 0000000000..e61296e11a > > > --- /dev/null > > > +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > @@ -0,0 +1,71 @@ > > > +## @file > > > > > > +# Instance of PCD Library using PCD Protocol. > > > > > > +# > > > > > > +# There are two PCD protocols as follows: > > > > > > +# 1) PCD_PROTOCOL > > > > > > +# It is EDKII implementation which support Dynamic/DynamicEx Pcds. > > > > > > +# 2) EFI_PCD_PROTOCOL > > > > > > +# It is defined by PI specification 1.2, Vol 3 which only support dynamicEx > > > > > > +# type Pcd. > > > > > > +# > > > > > > +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL. > > > > > > +# > > > > > > +# This library instance uses the PCD_PROTOCOL to handle dynamic PCD request and use > > > > > > +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. > > > > > > +# > > > > > > +# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can only use this DxePcdLib > > > > > > +# in their initialization without any issues to access Dynamic and DynamicEx PCD. They can't > > > > > > +# access Dynamic and DynamicEx PCD in the implementation of runtime services and SMI handlers. > > > > > > +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in OS runtime phase. > > > > > > +# > > > > > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> > > > > > > +# > > > > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > +# > > > > > > +# > > > > > > +## > > > > > > + > > > > > > +[Defines] > > > > > > + INF_VERSION = 0x00010005 > > > > > > + BASE_NAME = DxePcdLib > > > > > > + MODULE_UNI_FILE = DxePcdLib.uni > > > > > > + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c > > > > > > + MODULE_TYPE = DXE_DRIVER > > > > > > + VERSION_STRING = 1.0 > > > > > > + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE > > UEFI_APPLICATION > > > UEFI_DRIVER > > > > > > + > > > > > > +# > > > > > > +# VALID_ARCHITECTURES = IA32 X64 EBC > > > > > > +# > > > > > > + > > > > > > +[Sources] > > > > > > + DxePcdLib.c > > > > > > + > > > > > > + > > > > > > +[Packages] > > > > > > + MdePkg/MdePkg.dec > > > > > > + > > > > > > + > > > > > > +[LibraryClasses] > > > > > > + BaseMemoryLib > > > > > > + UefiBootServicesTableLib > > > > > > + DebugLib > > > > > > + > > > > > > + > > > > > > +[Protocols] > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > + > > > > > > +[FeaturePcd] > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## CONSUMES > > > > > > + > > > > > > +[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > > Depex.common.DXE_SMM_DRIVER] > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid > > > > > > + > > > > > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > > > index b49f88d8e1..44f60e2086 100644 > > > --- a/MdePkg/MdePkg.dec > > > +++ b/MdePkg/MdePkg.dec > > > @@ -1000,6 +1000,12 @@ > > > ## Include/Protocol/PcdInfo.h > > > > > > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > > > > > > > > > + ## Payload Standalone Pcd Protocol > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, > 0x7d, > > > 0xc9, 0x1f}} > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, 0xae76, 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, > 0x04, > > > 0x4d, 0xea}} > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, > 0x14, > > > 0x5e, 0x15}} > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, > 0xa9, > > > 0x68, 0x9e}} > > > > > > + > > > > > > # > > > > > > # Protocols defined in PI1.0. > > > > > > # > > > > > > @@ -1945,6 +1951,12 @@ > > > # @Prompt Validate ORDERED_COLLECTION structure > > > > > > gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEAN|0x0000002a > > > > > > > > > > > > + ## Indicates if the standalone PCD database is enabled for Payload.<BR><BR> > > > > > > + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> > > > > > > + # FALSE - Disable tandalone PCD database is enabled for Payload.<BR> > > > > > > + # @Prompt Enable tandalone PCD database is enabled for Payload. > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOOLEAN|0x0000002e > > > > > > + > > > > > > [PcdsFixedAtBuild] > > > > > > ## Status code value for indicating a watchdog timer has expired. > > > > > > # EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_TIMER_EXPIRED > > > > > > -- > > > 2.30.0.windows.2 > > > > > > > > > > > > -=-=-=-=-=-= > > > Groups.io Links: You receive all messages sent to this group. > > > View/Reply Online (#75502): https://edk2.groups.io/g/devel/message/75502 > > > Mute This Topic: https://groups.io/mt/83046935/1643496 > > > Group Owner: devel+owner@edk2.groups.io > > > Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kinney@intel.com] > > > -=-=-=-=-=-= > > > > > > > > > > > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-25 14:35 ` Michael D Kinney @ 2021-05-26 2:03 ` Ni, Ray 2021-05-26 17:47 ` Michael D Kinney 0 siblings, 1 reply; 10+ messages in thread From: Ni, Ray @ 2021-05-26 2:03 UTC (permalink / raw) To: Kinney, Michael D, devel@edk2.groups.io, Liu, Zhiguang; +Cc: Liming Gao Mike, I totally agree with you on the restriction: Drivers in universal payload don't use dynamic(ex) PCDs. That's the final state. In phase #1, we need to separate the PCD database so that drivers inside universal payload don't consume any dynamic(ex) PCDs outside. For example, PciHostBridgeDxe produces the *PcdPciDisableBusEnumeration* and PciBusDxe consumes it. Both drivers are inside universal payload. PCD value is produced based on the information got from universal payload interfaces. In phase #2, we will update all drivers inside universal payload to avoid relying on dynamic PCDs. For example, we will update PciBusDxe to directly consume the https://universalpayload.github.io/documentation/payload-interfaces/index.html#pci-root-bridges to decide whether bus enumeration should be performed. We are in phase #1 now. In this phase, using of dynamic PCD is an implementation choice of the universal payload. And we need to make sure that any new universal payload module developed should not rely on dynamic PCD. To move to phase #2, I think we need all platforms to align to universal payload. Otherwise, PciBusDxe cannot get the PLD_PCI_ROOT_BRIDGE.ResourceAssigned from HOB. Is this week's TianoCore open design meeting ok for discussion? Thanks, Ray > -----Original Message----- > From: Kinney, Michael D <michael.d.kinney@intel.com> > Sent: Tuesday, May 25, 2021 10:35 PM > To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Liu, Zhiguang > <zhiguang.liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > Hi Ray, > > The PCD Database is intended to be owned by the platform FW. > > The concept of a universal payload that is loaded after the platform FW is > similar in > concept to loading a UEFI app/driver/osloader. Those types of loadable UEFI > components > are not allowed to use the PCD services > > The only time the PCD PPI/Protocol are accessed is if the PCD type is Dynamic > or > DynamicEx. > > Why do components in the Universal Payload need to access PCDs of type > Dynamic > or DynamicEx? Can we restrict components in the Universal Payload to only > use > PCDs of type FeatureFlag/FixedAtBuild/PatchableInModule? > > Thanks, > > Mike > > > -----Original Message----- > > From: Ni, Ray <ray.ni@intel.com> > > Sent: Monday, May 24, 2021 6:33 PM > > To: devel@edk2.groups.io; Kinney, Michael D > <michael.d.kinney@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > Mike, > > In payload phase, there are two kinds of payloads: > > 1. the universal payloads that conform to universal payload spec. These > payloads cannot depend on any PCD produced from > > bootloader phase. > > 2. the platform payloads. These payloads are developed by the same > vendor as the bootloader. So, they can depend on the > > PCD produced by the bootloader. The ultimate goal is these platform > payloads can be eliminated. > > > > Thanks, > > Ray > > > > > -----Original Message----- > > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > Michael D Kinney > > > Sent: Tuesday, May 25, 2021 4:30 AM > > > To: devel@edk2.groups.io; Liu, Zhiguang <zhiguang.liu@intel.com>; > Kinney, Michael D <michael.d.kinney@intel.com> > > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > > Subject: Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > > > Why do we need a new PCD? > > > > > > Can't we make this the default behavior to only install one instance? > > > > > > Thanks, > > > > > > Mike > > > > > > > -----Original Message----- > > > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > Zhiguang Liu > > > > Sent: Monday, May 24, 2021 2:25 AM > > > > To: devel@edk2.groups.io > > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao > <gaoliming@byosoft.com.cn> > > > > Subject: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > > > > > Add a feature PCD to control if the PCD driver is build as standalone > mode. > > > > This way, two mode PCD driver won't share the data base. > > > > > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > > > --- > > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 > +++++++++++++++++++++++++++++++++++++++++++++++++++------------ > --- > > > ------- > > > > -- > > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- > > > > MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- > > > > MdePkg/Include/Protocol/Pcd.h | 5 ----- > > > > MdePkg/Include/Protocol/PcdInfo.h | 5 ----- > > > > MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 > ++++++++++++++++++++---- > > > > MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- > > > > MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > +++++++++++++ > > > > MdePkg/MdePkg.dec | 12 ++++++++++++ > > > > 9 files changed, 184 insertions(+), 47 deletions(-) > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > > index cdb9b4fac1..dc9c4be022 100644 > > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > > @@ -129,34 +129,61 @@ PcdDxeInit ( > > > > // > > > > > > > > // Make sure the Pcd Protocol is not already installed in the system > > > > > > > > // > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > &gEdkiiPayloadStandalonePcdProtocolGuid); > > > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > > > > > - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > &gPcdProtocolGuid); > > > > > > > > + // > > > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > > > + // > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > + &mPcdHandle, > > > > > > > > + &gEdkiiPayloadStandalonePcdProtocolGuid, > &mPcdInstance, > > > > > > > > + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, > &mEfiPcdInstance, > > > > > > > > + NULL > > > > > > > > + ); > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > > > > > - BuildPcdDxeDataBase (); > > > > > > > > + // > > > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type > PCD > > > > > > > > + // > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > + &mPcdHandle, > > > > > > > > + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, > &mGetPcdInfoInstance, > > > > > > > > + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, > &mEfiGetPcdInfoInstance, > > > > > > > > + NULL > > > > > > > > + ); > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > + } else { > > > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > &gPcdProtocolGuid); > > > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > > > > > - // > > > > > > > > - // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > > > - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > > > - // > > > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > - &mPcdHandle, > > > > > > > > - &gPcdProtocolGuid, &mPcdInstance, > > > > > > > > - &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > > > - NULL > > > > > > > > - ); > > > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > > > + // > > > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > > > + // > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > + &mPcdHandle, > > > > > > > > + &gPcdProtocolGuid, &mPcdInstance, > > > > > > > > + &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > > > + NULL > > > > > > > > + ); > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > > > > > - // > > > > > > > > - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > > > - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type > PCD > > > > > > > > - // > > > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > - &mPcdHandle, > > > > > > > > - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > > > - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > > > - NULL > > > > > > > > - ); > > > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > > > + // > > > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type > PCD > > > > > > > > + // > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > + &mPcdHandle, > > > > > > > > + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > > > + &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > > > + NULL > > > > > > > > + ); > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > + } > > > > > > > > > > > > > > > > // > > > > > > > > // Register callback function upon VariableLockProtocol > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > > index eb9f757f14..f3e704f083 100644 > > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > > @@ -329,10 +329,15 @@ > > > > gEfiMdeModulePkgTokenSpaceGuid ## > SOMETIMES_CONSUMES ## GUID > > > > > > > > > > > > > > > > [Protocols] > > > > > > > > - gPcdProtocolGuid ## PRODUCES > > > > > > > > - gEfiPcdProtocolGuid ## PRODUCES > > > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > + gPcdProtocolGuid ## PRODUCES > > > > > > > > + gEfiPcdProtocolGuid ## PRODUCES > > > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > + > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_PRODUCES > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_PRODUCES > > > > > > > > ## NOTIFY > > > > > > > > ## SOMETIMES_CONSUMES > > > > > > > > gEdkiiVariableLockProtocolGuid > > > > > > > > @@ -342,6 +347,9 @@ > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## > SOMETIMES_CONSUMES > > > > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## > SOMETIMES_CONSUMES > > > > > > > > > > > > > > > > +[FeaturePcd] > > > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > CONSUMES > > > > > > > > + > > > > > > > > [Depex] > > > > > > > > TRUE > > > > > > > > > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c > b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > > index ea7edc3cbb..fe16ba713b 100644 > > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > > @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( > > > > CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb- > >Length); > > > > > > > > mPcdDatabase.DxeDb = PcdDxeDb; > > > > > > > > > > > > > > > > - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > + GuidHob = NULL; > > > > > > > > + } else { > > > > > > > > + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > > > + } > > > > > > > > + > > > > > > > > if (GuidHob != NULL) { > > > > > > > > > > > > > > > > // > > > > > > > > diff --git a/MdePkg/Include/Protocol/Pcd.h > b/MdePkg/Include/Protocol/Pcd.h > > > > index 9cd1a998f8..cfa6ac2360 100644 > > > > --- a/MdePkg/Include/Protocol/Pcd.h > > > > +++ b/MdePkg/Include/Protocol/Pcd.h > > > > @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > > #ifndef __PCD_H__ > > > > > > > > #define __PCD_H__ > > > > > > > > > > > > > > > > -extern EFI_GUID gPcdProtocolGuid; > > > > > > > > - > > > > > > > > -#define PCD_PROTOCOL_GUID \ > > > > > > > > - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, > 0xe, 0xf7 } } > > > > > > > > - > > > > > > > > #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/MdePkg/Include/Protocol/PcdInfo.h > b/MdePkg/Include/Protocol/PcdInfo.h > > > > index b0ec7f6770..5691215c42 100644 > > > > --- a/MdePkg/Include/Protocol/PcdInfo.h > > > > +++ b/MdePkg/Include/Protocol/PcdInfo.h > > > > @@ -19,11 +19,6 @@ > > > > #ifndef __PCD_INFO_H__ > > > > > > > > #define __PCD_INFO_H__ > > > > > > > > > > > > > > > > -extern EFI_GUID gGetPcdInfoProtocolGuid; > > > > > > > > - > > > > > > > > -#define GET_PCD_INFO_PROTOCOL_GUID \ > > > > > > > > - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, > 0xd3, 0x65 } } > > > > > > > > - > > > > > > > > /// > > > > > > > > /// The forward declaration for GET_PCD_INFO_PROTOCOL. > > > > > > > > /// > > > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c > b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > > index 2accaeda2c..8a61486832 100644 > > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > > @@ -43,7 +43,11 @@ GetPiPcdProtocol ( > > > > // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the > module > > > > > > > > // access DynamicEx type PCD. > > > > > > > > // > > > > > > > > - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID > **) &mPiPcd); > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > + Status = gBS->LocateProtocol > (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > > > > > + } else { > > > > > > > > + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID > **) &mPiPcd); > > > > > > > > + } > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > ASSERT (mPiPcd != NULL); > > > > > > > > } > > > > > > > > @@ -68,7 +72,11 @@ GetPcdProtocol ( > > > > // PCD protocol need to be installed before the module access > Dynamic type PCD. > > > > > > > > // But dynamic type PCD is not required in PI 1.2 specification. > > > > > > > > // > > > > > > > > - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > **)&mPcd); > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > + Status = gBS->LocateProtocol > (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > > > > > + } else { > > > > > > > > + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > **)&mPcd); > > > > > > > > + } > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > ASSERT (mPcd != NULL); > > > > > > > > } > > > > > > > > @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( > > > > EFI_STATUS Status; > > > > > > > > > > > > > > > > if (mPiPcdInfo == NULL) { > > > > > > > > - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, > (VOID **)&mPiPcdInfo); > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > + Status = gBS->LocateProtocol > (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > **)&mPiPcdInfo); > > > > > > > > + } else{ > > > > > > > > + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, > (VOID **)&mPiPcdInfo); > > > > > > > > + } > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > ASSERT (mPiPcdInfo != NULL); > > > > > > > > } > > > > > > > > @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( > > > > EFI_STATUS Status; > > > > > > > > > > > > > > > > if (mPcdInfo == NULL) { > > > > > > > > - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, > (VOID **)&mPcdInfo); > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > + Status = gBS->LocateProtocol > (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > **)&mPcdInfo); > > > > > > > > + } else { > > > > > > > > + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, > (VOID **)&mPcdInfo); > > > > > > > > + } > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > ASSERT (mPcdInfo != NULL); > > > > > > > > } > > > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > > index 3d4d21b442..59d9fe4f11 100644 > > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > > @@ -53,10 +53,18 @@ > > > > > > > > > > > > > > > > > > > > [Protocols] > > > > > > > > - gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > - gEfiPcdProtocolGuid ## CONSUMES > > > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + > > > > > > > > +[FeaturePcd] > > > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > CONSUMES > > > > > > > > > > > > > > > > [Depex.common.DXE_DRIVER, > Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > > > Depex.common.DXE_SMM_DRIVER] > > > > > > > > gEfiPcdProtocolGuid > > > > > > > > diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > > new file mode 100644 > > > > index 0000000000..e61296e11a > > > > --- /dev/null > > > > +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > > @@ -0,0 +1,71 @@ > > > > +## @file > > > > > > > > +# Instance of PCD Library using PCD Protocol. > > > > > > > > +# > > > > > > > > +# There are two PCD protocols as follows: > > > > > > > > +# 1) PCD_PROTOCOL > > > > > > > > +# It is EDKII implementation which support Dynamic/DynamicEx > Pcds. > > > > > > > > +# 2) EFI_PCD_PROTOCOL > > > > > > > > +# It is defined by PI specification 1.2, Vol 3 which only support > dynamicEx > > > > > > > > +# type Pcd. > > > > > > > > +# > > > > > > > > +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL > and EFI_PCD_PROTOCOL. > > > > > > > > +# > > > > > > > > +# This library instance uses the PCD_PROTOCOL to handle dynamic > PCD request and use > > > > > > > > +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. > > > > > > > > +# > > > > > > > > +# Note: A driver of type DXE_RUNTIME_DRIVER and > DXE_SMM_DRIVER can only use this DxePcdLib > > > > > > > > +# in their initialization without any issues to access Dynamic and > DynamicEx PCD. They can't > > > > > > > > +# access Dynamic and DynamicEx PCD in the implementation of > runtime services and SMI handlers. > > > > > > > > +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in > OS runtime phase. > > > > > > > > +# > > > > > > > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> > > > > > > > > +# > > > > > > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > +# > > > > > > > > +# > > > > > > > > +## > > > > > > > > + > > > > > > > > +[Defines] > > > > > > > > + INF_VERSION = 0x00010005 > > > > > > > > + BASE_NAME = DxePcdLib > > > > > > > > + MODULE_UNI_FILE = DxePcdLib.uni > > > > > > > > + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c > > > > > > > > + MODULE_TYPE = DXE_DRIVER > > > > > > > > + VERSION_STRING = 1.0 > > > > > > > > + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER > DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE > > > UEFI_APPLICATION > > > > UEFI_DRIVER > > > > > > > > + > > > > > > > > +# > > > > > > > > +# VALID_ARCHITECTURES = IA32 X64 EBC > > > > > > > > +# > > > > > > > > + > > > > > > > > +[Sources] > > > > > > > > + DxePcdLib.c > > > > > > > > + > > > > > > > > + > > > > > > > > +[Packages] > > > > > > > > + MdePkg/MdePkg.dec > > > > > > > > + > > > > > > > > + > > > > > > > > +[LibraryClasses] > > > > > > > > + BaseMemoryLib > > > > > > > > + UefiBootServicesTableLib > > > > > > > > + DebugLib > > > > > > > > + > > > > > > > > + > > > > > > > > +[Protocols] > > > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > + > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > SOMETIMES_CONSUMES > > > > > > > > + > > > > > > > > +[FeaturePcd] > > > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > CONSUMES > > > > > > > > + > > > > > > > > +[Depex.common.DXE_DRIVER, > Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > > > Depex.common.DXE_SMM_DRIVER] > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid > > > > > > > > + > > > > > > > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > > > > index b49f88d8e1..44f60e2086 100644 > > > > --- a/MdePkg/MdePkg.dec > > > > +++ b/MdePkg/MdePkg.dec > > > > @@ -1000,6 +1000,12 @@ > > > > ## Include/Protocol/PcdInfo.h > > > > > > > > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, > 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > > > > > > > > > > > > > + ## Payload Standalone Pcd Protocol > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, > 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, > > 0x7d, > > > > 0xc9, 0x1f}} > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, > 0xae76, 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, > > 0x04, > > > > 0x4d, 0xea}} > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, > 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, > > 0x14, > > > > 0x5e, 0x15}} > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, > 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, > > 0xa9, > > > > 0x68, 0x9e}} > > > > > > > > + > > > > > > > > # > > > > > > > > # Protocols defined in PI1.0. > > > > > > > > # > > > > > > > > @@ -1945,6 +1951,12 @@ > > > > # @Prompt Validate ORDERED_COLLECTION structure > > > > > > > > > gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEA > N|0x0000002a > > > > > > > > > > > > > > > > + ## Indicates if the standalone PCD database is enabled for > Payload.<BR><BR> > > > > > > > > + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> > > > > > > > > + # FALSE - Disable tandalone PCD database is enabled for > Payload.<BR> > > > > > > > > + # @Prompt Enable tandalone PCD database is enabled for Payload. > > > > > > > > + > gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOO > LEAN|0x0000002e > > > > > > > > + > > > > > > > > [PcdsFixedAtBuild] > > > > > > > > ## Status code value for indicating a watchdog timer has expired. > > > > > > > > # EFI_COMPUTING_UNIT_HOST_PROCESSOR | > EFI_CU_HP_EC_TIMER_EXPIRED > > > > > > > > -- > > > > 2.30.0.windows.2 > > > > > > > > > > > > > > > > -=-=-=-=-=-= > > > > Groups.io Links: You receive all messages sent to this group. > > > > View/Reply Online (#75502): > https://edk2.groups.io/g/devel/message/75502 > > > > Mute This Topic: https://groups.io/mt/83046935/1643496 > > > > Group Owner: devel+owner@edk2.groups.io > > > > Unsubscribe: https://edk2.groups.io/g/devel/unsub > [michael.d.kinney@intel.com] > > > > -=-=-=-=-=-= > > > > > > > > > > > > > > > > > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver 2021-05-26 2:03 ` Ni, Ray @ 2021-05-26 17:47 ` Michael D Kinney 0 siblings, 0 replies; 10+ messages in thread From: Michael D Kinney @ 2021-05-26 17:47 UTC (permalink / raw) To: Ni, Ray, devel@edk2.groups.io, Liu, Zhiguang, Kinney, Michael D Cc: Liming Gao Hi Ray, Can we work through these phases in the edk2-staging repo and avoid making temp changes to the edk2 repo? Thanks, Mike > -----Original Message----- > From: Ni, Ray <ray.ni@intel.com> > Sent: Tuesday, May 25, 2021 7:03 PM > To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io; Liu, Zhiguang <zhiguang.liu@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > Mike, > I totally agree with you on the restriction: Drivers in universal payload don't use dynamic(ex) PCDs. > That's the final state. > > In phase #1, we need to separate the PCD database so that drivers inside universal payload don't consume any dynamic(ex) > PCDs outside. For example, PciHostBridgeDxe produces the *PcdPciDisableBusEnumeration* and PciBusDxe consumes it. > Both drivers are inside universal payload. PCD value is produced based on the information got from universal payload > interfaces. > > In phase #2, we will update all drivers inside universal payload to avoid relying on dynamic PCDs. For example, we will > update PciBusDxe to directly consume the https://universalpayload.github.io/documentation/payload- > interfaces/index.html#pci-root-bridges to decide whether bus enumeration should be performed. > > We are in phase #1 now. In this phase, using of dynamic PCD is an implementation choice of the universal payload. And we > need to make sure that any new universal payload module developed should not rely on dynamic PCD. > > To move to phase #2, I think we need all platforms to align to universal payload. Otherwise, PciBusDxe cannot get the > PLD_PCI_ROOT_BRIDGE.ResourceAssigned from HOB. > > Is this week's TianoCore open design meeting ok for discussion? > > Thanks, > Ray > > > > -----Original Message----- > > From: Kinney, Michael D <michael.d.kinney@intel.com> > > Sent: Tuesday, May 25, 2021 10:35 PM > > To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Liu, Zhiguang > > <zhiguang.liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > Hi Ray, > > > > The PCD Database is intended to be owned by the platform FW. > > > > The concept of a universal payload that is loaded after the platform FW is > > similar in > > concept to loading a UEFI app/driver/osloader. Those types of loadable UEFI > > components > > are not allowed to use the PCD services > > > > The only time the PCD PPI/Protocol are accessed is if the PCD type is Dynamic > > or > > DynamicEx. > > > > Why do components in the Universal Payload need to access PCDs of type > > Dynamic > > or DynamicEx? Can we restrict components in the Universal Payload to only > > use > > PCDs of type FeatureFlag/FixedAtBuild/PatchableInModule? > > > > Thanks, > > > > Mike > > > > > -----Original Message----- > > > From: Ni, Ray <ray.ni@intel.com> > > > Sent: Monday, May 24, 2021 6:33 PM > > > To: devel@edk2.groups.io; Kinney, Michael D > > <michael.d.kinney@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com> > > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > > Subject: RE: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > > > Mike, > > > In payload phase, there are two kinds of payloads: > > > 1. the universal payloads that conform to universal payload spec. These > > payloads cannot depend on any PCD produced from > > > bootloader phase. > > > 2. the platform payloads. These payloads are developed by the same > > vendor as the bootloader. So, they can depend on the > > > PCD produced by the bootloader. The ultimate goal is these platform > > payloads can be eliminated. > > > > > > Thanks, > > > Ray > > > > > > > -----Original Message----- > > > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > > Michael D Kinney > > > > Sent: Tuesday, May 25, 2021 4:30 AM > > > > To: devel@edk2.groups.io; Liu, Zhiguang <zhiguang.liu@intel.com>; > > Kinney, Michael D <michael.d.kinney@intel.com> > > > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > > > Subject: Re: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > > > > > Why do we need a new PCD? > > > > > > > > Can't we make this the default behavior to only install one instance? > > > > > > > > Thanks, > > > > > > > > Mike > > > > > > > > > -----Original Message----- > > > > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > > Zhiguang Liu > > > > > Sent: Monday, May 24, 2021 2:25 AM > > > > > To: devel@edk2.groups.io > > > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao > > <gaoliming@byosoft.com.cn> > > > > > Subject: [edk2-devel] [PATCH 1/2] MdePkg: Standalone PCD driver > > > > > > > > > > Add a feature PCD to control if the PCD driver is build as standalone > > mode. > > > > > This way, two mode PCD driver won't share the data base. > > > > > > > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > > > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > > > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> > > > > > --- > > > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 75 > > +++++++++++++++++++++++++++++++++++++++++++++++++++------------ > > --- > > > > ------- > > > > > -- > > > > > MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 16 ++++++++++++---- > > > > > MdeModulePkg/Universal/PCD/Dxe/Service.c | 7 ++++++- > > > > > MdePkg/Include/Protocol/Pcd.h | 5 ----- > > > > > MdePkg/Include/Protocol/PcdInfo.h | 5 ----- > > > > > MdePkg/Library/DxePcdLib/DxePcdLib.c | 24 > > ++++++++++++++++++++---- > > > > > MdePkg/Library/DxePcdLib/DxePcdLib.inf | 16 ++++++++++++---- > > > > > MdePkg/Library/DxePcdLib/PayloadPcdLib.inf | 71 > > > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > +++++++++++++ > > > > > MdePkg/MdePkg.dec | 12 ++++++++++++ > > > > > 9 files changed, 184 insertions(+), 47 deletions(-) > > > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > > > index cdb9b4fac1..dc9c4be022 100644 > > > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > > > > > @@ -129,34 +129,61 @@ PcdDxeInit ( > > > > > // > > > > > > > > > > // Make sure the Pcd Protocol is not already installed in the system > > > > > > > > > > // > > > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > > &gEdkiiPayloadStandalonePcdProtocolGuid); > > > > > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > > > > > > > > > - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > > &gPcdProtocolGuid); > > > > > > > > > > + // > > > > > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > > > > > + // > > > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > > > + &mPcdHandle, > > > > > > > > > > + &gEdkiiPayloadStandalonePcdProtocolGuid, > > &mPcdInstance, > > > > > > > > > > + &gEdkiiEfiPayloadStandalonePcdProtocolGuid, > > &mEfiPcdInstance, > > > > > > > > > > + NULL > > > > > > > > > > + ); > > > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > > > > > > > > > - BuildPcdDxeDataBase (); > > > > > > > > > > + // > > > > > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type > > PCD > > > > > > > > > > + // > > > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > > > + &mPcdHandle, > > > > > > > > > > + &gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, > > &mGetPcdInfoInstance, > > > > > > > > > > + &gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, > > &mEfiGetPcdInfoInstance, > > > > > > > > > > + NULL > > > > > > > > > > + ); > > > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > + } else { > > > > > > > > > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > > &gPcdProtocolGuid); > > > > > > > > > > + BuildPcdDxeDataBase (); > > > > > > > > > > > > > > > > > > > > - // > > > > > > > > > > - // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > > > > > - // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > > > > > - // > > > > > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > > > - &mPcdHandle, > > > > > > > > > > - &gPcdProtocolGuid, &mPcdInstance, > > > > > > > > > > - &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > > > > > - NULL > > > > > > > > > > - ); > > > > > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > > > > > + // > > > > > > > > > > + // Install PCD_PROTOCOL to handle dynamic type PCD > > > > > > > > > > + // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD > > > > > > > > > > + // > > > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > > > + &mPcdHandle, > > > > > > > > > > + &gPcdProtocolGuid, &mPcdInstance, > > > > > > > > > > + &gEfiPcdProtocolGuid, &mEfiPcdInstance, > > > > > > > > > > + NULL > > > > > > > > > > + ); > > > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > > > > > > > > > > > - // > > > > > > > > > > - // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > > > > > - // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type > > PCD > > > > > > > > > > - // > > > > > > > > > > - Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > > > - &mPcdHandle, > > > > > > > > > > - &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > > > > > - &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > > > > > - NULL > > > > > > > > > > - ); > > > > > > > > > > - ASSERT_EFI_ERROR (Status); > > > > > > > > > > + // > > > > > > > > > > + // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD > > > > > > > > > > + // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type > > PCD > > > > > > > > > > + // > > > > > > > > > > + Status = gBS->InstallMultipleProtocolInterfaces ( > > > > > > > > > > + &mPcdHandle, > > > > > > > > > > + &gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance, > > > > > > > > > > + &gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance, > > > > > > > > > > + NULL > > > > > > > > > > + ); > > > > > > > > > > + ASSERT_EFI_ERROR (Status); > > > > > > > > > > + } > > > > > > > > > > > > > > > > > > > > // > > > > > > > > > > // Register callback function upon VariableLockProtocol > > > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > > > index eb9f757f14..f3e704f083 100644 > > > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > > > > @@ -329,10 +329,15 @@ > > > > > gEfiMdeModulePkgTokenSpaceGuid ## > > SOMETIMES_CONSUMES ## GUID > > > > > > > > > > > > > > > > > > > > [Protocols] > > > > > > > > > > - gPcdProtocolGuid ## PRODUCES > > > > > > > > > > - gEfiPcdProtocolGuid ## PRODUCES > > > > > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > > > + gPcdProtocolGuid ## PRODUCES > > > > > > > > > > + gEfiPcdProtocolGuid ## PRODUCES > > > > > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES > > > > > > > > > > + > > > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## PRODUCES > > > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_PRODUCES > > > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_PRODUCES > > > > > > > > > > ## NOTIFY > > > > > > > > > > ## SOMETIMES_CONSUMES > > > > > > > > > > gEdkiiVariableLockProtocolGuid > > > > > > > > > > @@ -342,6 +347,9 @@ > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress64 ## > > SOMETIMES_CONSUMES > > > > > > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## > > SOMETIMES_CONSUMES > > > > > > > > > > > > > > > > > > > > +[FeaturePcd] > > > > > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > > CONSUMES > > > > > > > > > > + > > > > > > > > > > [Depex] > > > > > > > > > > TRUE > > > > > > > > > > > > > > > > > > > > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > > > index ea7edc3cbb..fe16ba713b 100644 > > > > > --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > > > +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c > > > > > @@ -861,7 +861,12 @@ BuildPcdDxeDataBase ( > > > > > CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb- > > >Length); > > > > > > > > > > mPcdDatabase.DxeDb = PcdDxeDb; > > > > > > > > > > > > > > > > > > > > - GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > > > + GuidHob = NULL; > > > > > > > > > > + } else { > > > > > > > > > > + GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); > > > > > > > > > > + } > > > > > > > > > > + > > > > > > > > > > if (GuidHob != NULL) { > > > > > > > > > > > > > > > > > > > > // > > > > > > > > > > diff --git a/MdePkg/Include/Protocol/Pcd.h > > b/MdePkg/Include/Protocol/Pcd.h > > > > > index 9cd1a998f8..cfa6ac2360 100644 > > > > > --- a/MdePkg/Include/Protocol/Pcd.h > > > > > +++ b/MdePkg/Include/Protocol/Pcd.h > > > > > @@ -17,11 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > #ifndef __PCD_H__ > > > > > > > > > > #define __PCD_H__ > > > > > > > > > > > > > > > > > > > > -extern EFI_GUID gPcdProtocolGuid; > > > > > > > > > > - > > > > > > > > > > -#define PCD_PROTOCOL_GUID \ > > > > > > > > > > - { 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, > > 0xe, 0xf7 } } > > > > > > > > > > - > > > > > > > > > > #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/MdePkg/Include/Protocol/PcdInfo.h > > b/MdePkg/Include/Protocol/PcdInfo.h > > > > > index b0ec7f6770..5691215c42 100644 > > > > > --- a/MdePkg/Include/Protocol/PcdInfo.h > > > > > +++ b/MdePkg/Include/Protocol/PcdInfo.h > > > > > @@ -19,11 +19,6 @@ > > > > > #ifndef __PCD_INFO_H__ > > > > > > > > > > #define __PCD_INFO_H__ > > > > > > > > > > > > > > > > > > > > -extern EFI_GUID gGetPcdInfoProtocolGuid; > > > > > > > > > > - > > > > > > > > > > -#define GET_PCD_INFO_PROTOCOL_GUID \ > > > > > > > > > > - { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, > > 0xd3, 0x65 } } > > > > > > > > > > - > > > > > > > > > > /// > > > > > > > > > > /// The forward declaration for GET_PCD_INFO_PROTOCOL. > > > > > > > > > > /// > > > > > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > > > index 2accaeda2c..8a61486832 100644 > > > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c > > > > > @@ -43,7 +43,11 @@ GetPiPcdProtocol ( > > > > > // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the > > module > > > > > > > > > > // access DynamicEx type PCD. > > > > > > > > > > // > > > > > > > > > > - Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID > > **) &mPiPcd); > > > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > > > + Status = gBS->LocateProtocol > > (&gEdkiiEfiPayloadStandalonePcdProtocolGuid, NULL, (VOID **) &mPiPcd); > > > > > > > > > > + } else { > > > > > > > > > > + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID > > **) &mPiPcd); > > > > > > > > > > + } > > > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > > > ASSERT (mPiPcd != NULL); > > > > > > > > > > } > > > > > > > > > > @@ -68,7 +72,11 @@ GetPcdProtocol ( > > > > > // PCD protocol need to be installed before the module access > > Dynamic type PCD. > > > > > > > > > > // But dynamic type PCD is not required in PI 1.2 specification. > > > > > > > > > > // > > > > > > > > > > - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > > **)&mPcd); > > > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > > > + Status = gBS->LocateProtocol > > (&gEdkiiPayloadStandalonePcdProtocolGuid, NULL, (VOID **)&mPcd); > > > > > > > > > > + } else { > > > > > > > > > > + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID > > **)&mPcd); > > > > > > > > > > + } > > > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > > > ASSERT (mPcd != NULL); > > > > > > > > > > } > > > > > > > > > > @@ -88,7 +96,11 @@ GetPiPcdInfoProtocolPointer ( > > > > > EFI_STATUS Status; > > > > > > > > > > > > > > > > > > > > if (mPiPcdInfo == NULL) { > > > > > > > > > > - Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, > > (VOID **)&mPiPcdInfo); > > > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > > > + Status = gBS->LocateProtocol > > (&gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > > **)&mPiPcdInfo); > > > > > > > > > > + } else{ > > > > > > > > > > + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, > > (VOID **)&mPiPcdInfo); > > > > > > > > > > + } > > > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > > > ASSERT (mPiPcdInfo != NULL); > > > > > > > > > > } > > > > > > > > > > @@ -108,7 +120,11 @@ GetPcdInfoProtocolPointer ( > > > > > EFI_STATUS Status; > > > > > > > > > > > > > > > > > > > > if (mPcdInfo == NULL) { > > > > > > > > > > - Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, > > (VOID **)&mPcdInfo); > > > > > > > > > > + if (FeaturePcdGet (PcdStandalonePcdDatabaseEnable)) { > > > > > > > > > > + Status = gBS->LocateProtocol > > (&gEdkiiPayloadGetStandalonePcdInfoProtocolGuid, NULL, (VOID > > **)&mPcdInfo); > > > > > > > > > > + } else { > > > > > > > > > > + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, > > (VOID **)&mPcdInfo); > > > > > > > > > > + } > > > > > > > > > > ASSERT_EFI_ERROR (Status); > > > > > > > > > > ASSERT (mPcdInfo != NULL); > > > > > > > > > > } > > > > > > > > > > diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > > > index 3d4d21b442..59d9fe4f11 100644 > > > > > --- a/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > > > +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.inf > > > > > @@ -53,10 +53,18 @@ > > > > > > > > > > > > > > > > > > > > > > > > > [Protocols] > > > > > > > > > > - gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > - gEfiPcdProtocolGuid ## CONSUMES > > > > > > > > > > - gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > - gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + > > > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + > > > > > > > > > > +[FeaturePcd] > > > > > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > > CONSUMES > > > > > > > > > > > > > > > > > > > > [Depex.common.DXE_DRIVER, > > Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > > > > Depex.common.DXE_SMM_DRIVER] > > > > > > > > > > gEfiPcdProtocolGuid > > > > > > > > > > diff --git a/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > > > new file mode 100644 > > > > > index 0000000000..e61296e11a > > > > > --- /dev/null > > > > > +++ b/MdePkg/Library/DxePcdLib/PayloadPcdLib.inf > > > > > @@ -0,0 +1,71 @@ > > > > > +## @file > > > > > > > > > > +# Instance of PCD Library using PCD Protocol. > > > > > > > > > > +# > > > > > > > > > > +# There are two PCD protocols as follows: > > > > > > > > > > +# 1) PCD_PROTOCOL > > > > > > > > > > +# It is EDKII implementation which support Dynamic/DynamicEx > > Pcds. > > > > > > > > > > +# 2) EFI_PCD_PROTOCOL > > > > > > > > > > +# It is defined by PI specification 1.2, Vol 3 which only support > > dynamicEx > > > > > > > > > > +# type Pcd. > > > > > > > > > > +# > > > > > > > > > > +# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL > > and EFI_PCD_PROTOCOL. > > > > > > > > > > +# > > > > > > > > > > +# This library instance uses the PCD_PROTOCOL to handle dynamic > > PCD request and use > > > > > > > > > > +# EFI_PCD_PROTOCOL to handle dynamicEx type PCD. > > > > > > > > > > +# > > > > > > > > > > +# Note: A driver of type DXE_RUNTIME_DRIVER and > > DXE_SMM_DRIVER can only use this DxePcdLib > > > > > > > > > > +# in their initialization without any issues to access Dynamic and > > DynamicEx PCD. They can't > > > > > > > > > > +# access Dynamic and DynamicEx PCD in the implementation of > > runtime services and SMI handlers. > > > > > > > > > > +# Because EFI_PCD_PROTOCOL is DXE protocol that is not available in > > OS runtime phase. > > > > > > > > > > +# > > > > > > > > > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> > > > > > > > > > > +# > > > > > > > > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > > > +# > > > > > > > > > > +# > > > > > > > > > > +## > > > > > > > > > > + > > > > > > > > > > +[Defines] > > > > > > > > > > + INF_VERSION = 0x00010005 > > > > > > > > > > + BASE_NAME = DxePcdLib > > > > > > > > > > + MODULE_UNI_FILE = DxePcdLib.uni > > > > > > > > > > + FILE_GUID = f9af2f38-09e2-4ff1-b661-5d1c19d9f75c > > > > > > > > > > + MODULE_TYPE = DXE_DRIVER > > > > > > > > > > + VERSION_STRING = 1.0 > > > > > > > > > > + LIBRARY_CLASS = PcdLib|DXE_CORE DXE_DRIVER > > DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE > > > > UEFI_APPLICATION > > > > > UEFI_DRIVER > > > > > > > > > > + > > > > > > > > > > +# > > > > > > > > > > +# VALID_ARCHITECTURES = IA32 X64 EBC > > > > > > > > > > +# > > > > > > > > > > + > > > > > > > > > > +[Sources] > > > > > > > > > > + DxePcdLib.c > > > > > > > > > > + > > > > > > > > > > + > > > > > > > > > > +[Packages] > > > > > > > > > > + MdePkg/MdePkg.dec > > > > > > > > > > + > > > > > > > > > > + > > > > > > > > > > +[LibraryClasses] > > > > > > > > > > + BaseMemoryLib > > > > > > > > > > + UefiBootServicesTableLib > > > > > > > > > > + DebugLib > > > > > > > > > > + > > > > > > > > > > + > > > > > > > > > > +[Protocols] > > > > > > > > > > + gPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + gEfiPcdProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES > > > > > > > > > > + > > > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid ## > > SOMETIMES_CONSUMES > > > > > > > > > > + > > > > > > > > > > +[FeaturePcd] > > > > > > > > > > + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable ## > > CONSUMES > > > > > > > > > > + > > > > > > > > > > +[Depex.common.DXE_DRIVER, > > Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, > > > > Depex.common.DXE_SMM_DRIVER] > > > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid > > > > > > > > > > + > > > > > > > > > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > > > > > index b49f88d8e1..44f60e2086 100644 > > > > > --- a/MdePkg/MdePkg.dec > > > > > +++ b/MdePkg/MdePkg.dec > > > > > @@ -1000,6 +1000,12 @@ > > > > > ## Include/Protocol/PcdInfo.h > > > > > > > > > > gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, > > 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } > > > > > > > > > > > > > > > > > > > > + ## Payload Standalone Pcd Protocol > > > > > > > > > > + gEdkiiPayloadStandalonePcdProtocolGuid = {0x8ef6ff48, 0x2260, > > 0x5407, {0x0d, 0x18, 0x2e, 0x2c, 0xaa, > > > 0x7d, > > > > > 0xc9, 0x1f}} > > > > > > > > > > + gEdkiiEfiPayloadStandalonePcdProtocolGuid = {0x7e50c422, > > 0xae76, 0xbdc9, {0x16, 0x66, 0xca, 0x67, 0x95, > > > 0x04, > > > > > 0x4d, 0xea}} > > > > > > > > > > + gEdkiiPayloadGetStandalonePcdInfoProtocolGuid = {0xd7214c03, > > 0x27e0, 0x5b35, {0xd5, 0xb1, 0xeb, 0x1a, 0x50, > > > 0x14, > > > > > 0x5e, 0x15}} > > > > > > > > > > + gEdkiiEfiPayloadGetStandalonePcdInfoProtocolGuid = {0x1039ecdf, > > 0x5908, 0xf76c, {0x51, 0xf9, 0xae, 0x09, 0xc5, > > > 0xa9, > > > > > 0x68, 0x9e}} > > > > > > > > > > + > > > > > > > > > > # > > > > > > > > > > # Protocols defined in PI1.0. > > > > > > > > > > # > > > > > > > > > > @@ -1945,6 +1951,12 @@ > > > > > # @Prompt Validate ORDERED_COLLECTION structure > > > > > > > > > > > > gEfiMdePkgTokenSpaceGuid.PcdValidateOrderedCollection|FALSE|BOOLEA > > N|0x0000002a > > > > > > > > > > > > > > > > > > > > + ## Indicates if the standalone PCD database is enabled for > > Payload.<BR><BR> > > > > > > > > > > + # TRUE - Enable tandalone PCD database is enabled for Payload.<BR> > > > > > > > > > > + # FALSE - Disable tandalone PCD database is enabled for > > Payload.<BR> > > > > > > > > > > + # @Prompt Enable tandalone PCD database is enabled for Payload. > > > > > > > > > > + > > gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|FALSE|BOO > > LEAN|0x0000002e > > > > > > > > > > + > > > > > > > > > > [PcdsFixedAtBuild] > > > > > > > > > > ## Status code value for indicating a watchdog timer has expired. > > > > > > > > > > # EFI_COMPUTING_UNIT_HOST_PROCESSOR | > > EFI_CU_HP_EC_TIMER_EXPIRED > > > > > > > > > > -- > > > > > 2.30.0.windows.2 > > > > > > > > > > > > > > > > > > > > -=-=-=-=-=-= > > > > > Groups.io Links: You receive all messages sent to this group. > > > > > View/Reply Online (#75502): > > https://edk2.groups.io/g/devel/message/75502 > > > > > Mute This Topic: https://groups.io/mt/83046935/1643496 > > > > > Group Owner: devel+owner@edk2.groups.io > > > > > Unsubscribe: https://edk2.groups.io/g/devel/unsub > > [michael.d.kinney@intel.com] > > > > > -=-=-=-=-=-= > > > > > > > > > > > > > > > > > > > > > > > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] UefiPayloadPkg: Use standalone PCD driver 2021-05-24 9:24 [PATCH 0/2] New feature to enable standalone PCD driver Zhiguang Liu 2021-05-24 9:24 ` [PATCH 1/2] MdePkg: Standalone " Zhiguang Liu @ 2021-05-24 9:24 ` Zhiguang Liu 1 sibling, 0 replies; 10+ messages in thread From: Zhiguang Liu @ 2021-05-24 9:24 UTC (permalink / raw) To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You Using standalone PCD driver need to change PcdLib and also set a feature PCD. Cc: Maurice Ma <maurice.ma@intel.com> Cc: Guo Dong <guo.dong@intel.com> Cc: Benjamin You <benjamin.you@intel.com> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> --- UefiPayloadPkg/UefiPayloadPkg.dsc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 37ad5a0ae7..425447a58f 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -237,7 +237,7 @@ VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf [LibraryClasses.common.DXE_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + PcdLib|MdePkg/Library/DxePcdLib/PayloadPcdLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf @@ -250,14 +250,14 @@ VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf [LibraryClasses.common.DXE_RUNTIME_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + PcdLib|MdePkg/Library/DxePcdLib/PayloadPcdLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf [LibraryClasses.common.UEFI_DRIVER,LibraryClasses.common.UEFI_APPLICATION] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + PcdLib|MdePkg/Library/DxePcdLib/PayloadPcdLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf @@ -271,6 +271,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE + gEfiMdePkgTokenSpaceGuid.PcdStandalonePcdDatabaseEnable|TRUE [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x10000 @@ -562,7 +563,7 @@ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + PcdLib|MdePkg/Library/DxePcdLib/PayloadPcdLib.inf ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf -- 2.30.0.windows.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-05-26 17:48 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-05-24 9:24 [PATCH 0/2] New feature to enable standalone PCD driver Zhiguang Liu 2021-05-24 9:24 ` [PATCH 1/2] MdePkg: Standalone " Zhiguang Liu 2021-05-24 20:29 ` [edk2-devel] " Michael D Kinney 2021-05-25 1:09 ` Zhiguang Liu 2021-05-25 14:18 ` Michael D Kinney 2021-05-25 1:33 ` Ni, Ray 2021-05-25 14:35 ` Michael D Kinney 2021-05-26 2:03 ` Ni, Ray 2021-05-26 17:47 ` Michael D Kinney 2021-05-24 9:24 ` [PATCH 2/2] UefiPayloadPkg: Use standalone " Zhiguang Liu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox