From: Eric Dong <eric.dong@intel.com>
To: edk2-devel@lists.01.org
Cc: Ruiyu Ni <ruiyu.ni@intel.com>, Laszlo Ersek <lersek@redhat.com>
Subject: [Patch] UefiCpuPkg/CpuFeatures: Export HOB if CPU initialized in PEI.
Date: Wed, 25 Oct 2017 15:58:39 +0800 [thread overview]
Message-ID: <1508918319-10232-1-git-send-email-eric.dong@intel.com> (raw)
In current implementation, CPU initialized can be done in PEI
or DXE phase. PEI uses CpuFeaturesPie and Dxe uses CpuFeaturesDxe.
If CPU initialized in PEI phase, CpuFeaturesDxe driver will
not be used. This driver will install gEdkiiCpuFeaturesInitDoneGuid
protocol after it initializes the CPU.
Some drivers depend on this protocol to dispatch themselves. If
CpuFeaturesDxe not been used, these drivers will not be dispatched.
This patch fix the above issue. If Cpu initialized in PEI
phase, it also report a guid HOB for CpuFeaturesDxe.
CpuFeaturesDxe will check this HOB first. If it found this
HOB, it just install gEdkiiCpuFeaturesInitDoneGuid protocol,
else it will also do the CPU initialization.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c | 19 +++++++++++++++++++
UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 1 +
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | 6 ++++++
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 1 +
4 files changed, 27 insertions(+)
diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c
index b0b186d..6c0ae9d 100644
--- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c
+++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c
@@ -19,6 +19,7 @@
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/RegisterCpuFeaturesLib.h>
+#include <Library/HobLib.h>
#include <Protocol/SmmConfiguration.h>
#include <Guid/CpuFeaturesInitDone.h>
@@ -101,6 +102,24 @@ CpuFeaturesDxeInitialize (
)
{
VOID *Registration;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) != NULL) {
+ //
+ // Try to find HOB first. This HOB exist means CPU features have
+ // been initialized by CpuFeaturesPei driver, just install gEdkiiCpuFeaturesInitDoneGuid.
+ //
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gEdkiiCpuFeaturesInitDoneGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+ return EFI_SUCCESS;
+ }
if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) {
//
diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf
index 175e8a9..b1733be 100644
--- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf
+++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf
@@ -33,6 +33,7 @@
UefiDriverEntryPoint
UefiBootServicesTableLib
RegisterCpuFeaturesLib
+ HobLib
[Sources]
CpuFeaturesDxe.c
diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c
index b052d55..72ee19b 100644
--- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c
+++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c
@@ -18,6 +18,7 @@
#include <Library/DebugLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/RegisterCpuFeaturesLib.h>
+#include <Library/HobLib.h>
#include <Guid/CpuFeaturesInitDone.h>
@@ -70,6 +71,11 @@ CpuFeaturesPeimInitialize (
Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc);
ASSERT_EFI_ERROR (Status);
+ //
+ // Build HOB to let CpuFeatureDxe driver skip the initialization process.
+ //
+ BuildGuidHob (&gEdkiiCpuFeaturesInitDoneGuid, 0);
+
return EFI_SUCCESS;
}
diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf
index dd4b388..e617c5b 100644
--- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf
+++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf
@@ -32,6 +32,7 @@
PeimEntryPoint
PeiServicesLib
RegisterCpuFeaturesLib
+ HobLib
[Sources]
CpuFeaturesPei.c
--
2.7.0.windows.1
next reply other threads:[~2017-10-25 7:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-25 7:58 Eric Dong [this message]
2017-10-25 14:11 ` [Patch] UefiCpuPkg/CpuFeatures: Export HOB if CPU initialized in PEI Ni, Ruiyu
2017-10-25 14:43 ` Laszlo Ersek
2017-10-26 2:25 ` Dong, Eric
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=1508918319-10232-1-git-send-email-eric.dong@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