summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2019-01-04 13:37:29 +0800
committerEric Dong <eric.dong@intel.com>2019-01-14 10:29:29 +0800
commit7217b8796d2727db76cd6684ba706c3b643b1d62 (patch)
tree3042362a806e8bf1f7863bc74eae6de7e03cf410 /UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
parenta6416d91c32e785259a8c07e1e2b767b754965b5 (diff)
downloadedk2-7217b8796d2727db76cd6684ba706c3b643b1d62.tar.gz
edk2-7217b8796d2727db76cd6684ba706c3b643b1d62.tar.bz2
edk2-7217b8796d2727db76cd6684ba706c3b643b1d62.zip
UefiCpuPkg/RegisterCpuFeaturesLib: Avoid AP calls PeiService.
V3: Define union to specify the ppi or protocol. V2: 1. Initialize CpuFeaturesData->MpService in CpuInitDataInitialize and make this function been called at the begin of the initialization. 2. let all other functions use CpuFeaturesData->MpService install of locate the protocol itself. V1: GetProcessorIndex function calls GetMpPpi to get the MP Ppi. Ap will calls GetProcessorIndex function which final let AP calls PeiService. This patch avoid GetProcessorIndex call PeiService. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1411 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c')
-rw-r--r--UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c59
1 files changed, 33 insertions, 26 deletions
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
index 926698dc95..3654c105ef 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
@@ -20,7 +20,6 @@
#include "RegisterCpuFeatures.h"
CPU_FEATURES_DATA mCpuFeaturesData = {0};
-EFI_MP_SERVICES_PROTOCOL *mCpuFeaturesMpServices = NULL;
/**
Worker function to get CPU_FEATURES_DATA pointer.
@@ -38,46 +37,46 @@ GetCpuFeaturesData (
/**
Worker function to get EFI_MP_SERVICES_PROTOCOL pointer.
- @return Pointer to EFI_MP_SERVICES_PROTOCOL.
+ @return MP_SERVICES variable.
**/
-EFI_MP_SERVICES_PROTOCOL *
-GetMpProtocol (
+MP_SERVICES
+GetMpService (
VOID
)
{
- EFI_STATUS Status;
-
- if (mCpuFeaturesMpServices == NULL) {
- //
- // Get MP Services Protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiMpServiceProtocolGuid,
- NULL,
- (VOID **)&mCpuFeaturesMpServices
- );
- ASSERT_EFI_ERROR (Status);
- }
+ EFI_STATUS Status;
+ MP_SERVICES MpService;
- ASSERT (mCpuFeaturesMpServices != NULL);
- return mCpuFeaturesMpServices;
+ //
+ // Get MP Services Protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiMpServiceProtocolGuid,
+ NULL,
+ (VOID **)&MpService.Protocol
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return MpService;
}
/**
Worker function to return processor index.
+ @param CpuFeaturesData Cpu Feature Data structure.
+
@return The processor index.
**/
UINTN
GetProcessorIndex (
- VOID
+ IN CPU_FEATURES_DATA *CpuFeaturesData
)
{
EFI_STATUS Status;
UINTN ProcessorIndex;
EFI_MP_SERVICES_PROTOCOL *MpServices;
- MpServices = GetMpProtocol ();
+ MpServices = CpuFeaturesData->MpService.Protocol;
Status = MpServices->WhoAmI(MpServices, &ProcessorIndex);
ASSERT_EFI_ERROR (Status);
return ProcessorIndex;
@@ -101,8 +100,11 @@ GetProcessorInformation (
{
EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices;
+ CPU_FEATURES_DATA *CpuFeaturesData;
+
+ CpuFeaturesData = GetCpuFeaturesData ();
+ MpServices = CpuFeaturesData->MpService.Protocol;
- MpServices = GetMpProtocol ();
Status = MpServices->GetProcessorInfo (
MpServices,
ProcessorNumber,
@@ -130,8 +132,8 @@ StartupAPsWorker (
CPU_FEATURES_DATA *CpuFeaturesData;
CpuFeaturesData = GetCpuFeaturesData ();
+ MpServices = CpuFeaturesData->MpService.Protocol;
- MpServices = GetMpProtocol ();
//
// Wakeup all APs
//
@@ -159,8 +161,11 @@ SwitchNewBsp (
{
EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices;
+ CPU_FEATURES_DATA *CpuFeaturesData;
+
+ CpuFeaturesData = GetCpuFeaturesData ();
+ MpServices = CpuFeaturesData->MpService.Protocol;
- MpServices = GetMpProtocol ();
//
// Wakeup all APs
//
@@ -190,8 +195,10 @@ GetNumberOfProcessor (
{
EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices;
+ CPU_FEATURES_DATA *CpuFeaturesData;
- MpServices = GetMpProtocol ();
+ CpuFeaturesData = GetCpuFeaturesData ();
+ MpServices = CpuFeaturesData->MpService.Protocol;
//
// Get the number of CPUs
@@ -225,7 +232,7 @@ CpuFeaturesInitialize (
CpuFeaturesData = GetCpuFeaturesData ();
- OldBspNumber = GetProcessorIndex();
+ OldBspNumber = GetProcessorIndex (CpuFeaturesData);
CpuFeaturesData->BspNumber = OldBspNumber;
Status = gBS->CreateEvent (