From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.17577.1599728640236814437 for ; Thu, 10 Sep 2020 02:04:00 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: chasel.chiu@intel.com) IronPort-SDR: 9NUlykh+creuOkB+nH8BQ2J+nnShaf0o0zWLv7wbdBoZ6U5ByOIFWKGf04DKik2+iPtGGbPdCQ c9kGk8tZHynQ== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="243312495" X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="243312495" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2020 02:03:46 -0700 IronPort-SDR: R1bzxXzDs18Yc22VJUhzVV+nJsSIZv0hlH0rthmwClkY+GuAi7CEAQeRP3SAlNymFil0mSB7cN stoy4d83JR4A== X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="480813287" Received: from cchiu4-mobl1.gar.corp.intel.com ([10.212.238.167]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 10 Sep 2020 02:03:45 -0700 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: Chasel Chiu , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar , Nate DeSimone Subject: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case. Date: Thu, 10 Sep 2020 17:02:33 +0800 Message-Id: <20200910090233.22784-1-chasel.chiu@intel.com> X-Mailer: git-send-email 2.13.3.windows.1 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2883 MpServices Ppi can be replaced by MpServices2 Ppi and MpServices2 Ppi is mandatory for RegisterCpuFeaturesLib functionality, basing on this we can drop MpServices Ppi usage from the library and the constraint that both Ppis must be installed. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Cc: Nate DeSimone Signed-off-by: Chasel Chiu --- UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c | 61 +++++++++++++++++++++++-------------------------------------- UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h | 6 +++--- 2 files changed, 26 insertions(+), 41 deletions(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c index 64768f7a74..4e558e9fee 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c @@ -1,7 +1,7 @@ /** @file CPU Register Table Library functions. - Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -11,7 +11,6 @@ #include #include #include -#include #include #include "RegisterCpuFeatures.h" @@ -75,10 +74,10 @@ GetMpService ( MP_SERVICES MpService; // - // Get MP Services Protocol + // Get MP Services2 Ppi // Status = PeiServicesLocatePpi ( - &gEfiPeiMpServicesPpiGuid, + &gEdkiiPeiMpServices2PpiGuid, 0, NULL, (VOID **)&MpService.Ppi @@ -100,17 +99,17 @@ GetProcessorIndex ( ) { EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi; UINTN ProcessorIndex; - CpuMpPpi = CpuFeaturesData->MpService.Ppi; + CpuMp2Ppi = CpuFeaturesData->MpService.Ppi; // // For two reasons which use NULL for WhoAmI: // 1. This function will be called by APs and AP should not use PeiServices Table // 2. Check WhoAmI implementation, this parameter will not be used. // - Status = CpuMpPpi->WhoAmI(NULL, CpuMpPpi, &ProcessorIndex); + Status = CpuMp2Ppi->WhoAmI (CpuMp2Ppi, &ProcessorIndex); ASSERT_EFI_ERROR (Status); return ProcessorIndex; } @@ -131,16 +130,15 @@ GetProcessorInformation ( OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer ) { - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi; EFI_STATUS Status; CPU_FEATURES_DATA *CpuFeaturesData; CpuFeaturesData = GetCpuFeaturesData (); - CpuMpPpi = CpuFeaturesData->MpService.Ppi; + CpuMp2Ppi = CpuFeaturesData->MpService.Ppi; - Status = CpuMpPpi->GetProcessorInfo ( - GetPeiServicesTablePointer(), - CpuMpPpi, + Status = CpuMp2Ppi->GetProcessorInfo ( + CpuMp2Ppi, ProcessorNumber, ProcessorInfoBuffer ); @@ -162,18 +160,17 @@ StartupAllAPsWorker ( ) { EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi; CPU_FEATURES_DATA *CpuFeaturesData; CpuFeaturesData = GetCpuFeaturesData (); - CpuMpPpi = CpuFeaturesData->MpService.Ppi; + CpuMp2Ppi = CpuFeaturesData->MpService.Ppi; // // Wakeup all APs for data collection. // - Status = CpuMpPpi->StartupAllAPs ( - GetPeiServicesTablePointer (), - CpuMpPpi, + Status = CpuMp2Ppi->StartupAllAPs ( + CpuMp2Ppi, Procedure, FALSE, 0, @@ -203,17 +200,7 @@ StartupAllCPUsWorker ( // // Get MP Services2 Ppi // - Status = PeiServicesLocatePpi ( - &gEdkiiPeiMpServices2PpiGuid, - 0, - NULL, - (VOID **)&CpuMp2Ppi - ); - ASSERT_EFI_ERROR (Status); - - // - // Wakeup all APs for data collection. - // + CpuMp2Ppi = CpuFeaturesData->MpService.Ppi; Status = CpuMp2Ppi->StartupAllCPUs ( CpuMp2Ppi, Procedure, @@ -234,18 +221,17 @@ SwitchNewBsp ( ) { EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi; CPU_FEATURES_DATA *CpuFeaturesData; CpuFeaturesData = GetCpuFeaturesData (); - CpuMpPpi = CpuFeaturesData->MpService.Ppi; + CpuMp2Ppi = CpuFeaturesData->MpService.Ppi; // // Wakeup all APs for data collection. // - Status = CpuMpPpi->SwitchBSP ( - GetPeiServicesTablePointer (), - CpuMpPpi, + Status = CpuMp2Ppi->SwitchBSP ( + CpuMp2Ppi, ProcessorNumber, TRUE ); @@ -269,18 +255,17 @@ GetNumberOfProcessor ( ) { EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi; CPU_FEATURES_DATA *CpuFeaturesData; CpuFeaturesData = GetCpuFeaturesData (); - CpuMpPpi = CpuFeaturesData->MpService.Ppi; + CpuMp2Ppi = CpuFeaturesData->MpService.Ppi; // // Get the number of CPUs // - Status = CpuMpPpi->GetNumberOfProcessors ( - GetPeiServicesTablePointer (), - CpuMpPpi, + Status = CpuMp2Ppi->GetNumberOfProcessors ( + CpuMp2Ppi, NumberOfCpus, NumberOfEnabledProcessors ); diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h index 53cb340b4c..e8a4aa644d 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h @@ -10,7 +10,7 @@ #define _REGISTER_CPU_FEATURES_H_ #include #include -#include +#include #include #include @@ -64,8 +64,8 @@ typedef struct { } PROGRAM_CPU_REGISTER_FLAGS; typedef union { - EFI_MP_SERVICES_PROTOCOL *Protocol; - EFI_PEI_MP_SERVICES_PPI *Ppi; + EFI_MP_SERVICES_PROTOCOL *Protocol; + EDKII_PEI_MP_SERVICES2_PPI *Ppi; } MP_SERVICES; typedef struct { -- 2.13.3.windows.1