From: "Zhiguang Liu" <zhiguang.liu@intel.com>
To: devel@edk2.groups.io
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH 1/2] MdePkg: Standalone PCD driver
Date: Mon, 24 May 2021 17:24:53 +0800 [thread overview]
Message-ID: <20210524092454.1168-2-zhiguang.liu@intel.com> (raw)
In-Reply-To: <20210524092454.1168-1-zhiguang.liu@intel.com>
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
next prev parent reply other threads:[~2021-05-24 9:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-24 9:24 [PATCH 0/2] New feature to enable standalone PCD driver Zhiguang Liu
2021-05-24 9:24 ` Zhiguang Liu [this message]
2021-05-24 20:29 ` [edk2-devel] [PATCH 1/2] MdePkg: Standalone " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210524092454.1168-2-zhiguang.liu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox