public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.
@ 2020-09-10  9:02 Chiu, Chasel
  2020-09-10 11:03 ` Laszlo Ersek
  2020-09-11  2:31 ` Dong, Eric
  0 siblings, 2 replies; 5+ messages in thread
From: Chiu, Chasel @ 2020-09-10  9:02 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Eric Dong, Ray Ni, Laszlo Ersek, Rahul Kumar,
	Nate DeSimone

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 <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 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.<BR>
+  Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -11,7 +11,6 @@
 #include <Library/HobLib.h>
 #include <Library/PeiServicesLib.h>
 #include <Library/PeiServicesTablePointerLib.h>
-#include <Ppi/MpServices.h>
 #include <Ppi/MpServices2.h>
 
 #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 <PiPei.h>
 #include <PiDxe.h>
-#include <Ppi/MpServices.h>
+#include <Ppi/MpServices2.h>
 #include <Protocol/MpService.h>
 
 #include <Library/BaseLib.h>
@@ -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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.
  2020-09-10  9:02 [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case Chiu, Chasel
@ 2020-09-10 11:03 ` Laszlo Ersek
  2020-09-11  2:31 ` Dong, Eric
  1 sibling, 0 replies; 5+ messages in thread
From: Laszlo Ersek @ 2020-09-10 11:03 UTC (permalink / raw)
  To: Chasel Chiu, devel; +Cc: Eric Dong, Ray Ni, Rahul Kumar, Nate DeSimone

Hi Chasel,

On 09/10/20 11:02, Chasel Chiu wrote:
> 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 <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  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.<BR>
> +  Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent
>  
>  **/
> @@ -11,7 +11,6 @@
>  #include <Library/HobLib.h>
>  #include <Library/PeiServicesLib.h>
>  #include <Library/PeiServicesTablePointerLib.h>
> -#include <Ppi/MpServices.h>
>  #include <Ppi/MpServices2.h>
>  
>  #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 <PiPei.h>
>  #include <PiDxe.h>
> -#include <Ppi/MpServices.h>
> +#include <Ppi/MpServices2.h>
>  #include <Protocol/MpService.h>
>  
>  #include <Library/BaseLib.h>
> @@ -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 {
> 

I defer to Eric and Ray on this patch.

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.
  2020-09-10  9:02 [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case Chiu, Chasel
  2020-09-10 11:03 ` Laszlo Ersek
@ 2020-09-11  2:31 ` Dong, Eric
  2020-09-11 18:37   ` Ni, Ray
  1 sibling, 1 reply; 5+ messages in thread
From: Dong, Eric @ 2020-09-11  2:31 UTC (permalink / raw)
  To: Chiu, Chasel, devel@edk2.groups.io
  Cc: Chiu, Chasel, Ni, Ray, Laszlo Ersek, Kumar, Rahul1,
	Desimone, Nathaniel L

Reviewed-by: Eric Dong <eric.dong@intel.com>

-----Original Message-----
From: Chasel Chiu <chasel.chiu@intel.com> 
Sent: Thursday, September 10, 2020 5:03 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.

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 <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 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/PeiRegisterCpuFeaturesLi
+++ b.c
@@ -1,7 +1,7 @@
 /** @file
   CPU Register Table Library functions.
 
-  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2020, Intel Corporation. All rights 
+ reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -11,7 +11,6 @@
 #include <Library/HobLib.h>
 #include <Library/PeiServicesLib.h>
 #include <Library/PeiServicesTablePointerLib.h>
-#include <Ppi/MpServices.h>
 #include <Ppi/MpServices2.h>
 
 #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 <PiPei.h>
 #include <PiDxe.h>
-#include <Ppi/MpServices.h>
+#include <Ppi/MpServices2.h>
 #include <Protocol/MpService.h>
 
 #include <Library/BaseLib.h>
@@ -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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.
  2020-09-11  2:31 ` Dong, Eric
@ 2020-09-11 18:37   ` Ni, Ray
  2020-09-14  0:50     ` Chiu, Chasel
  0 siblings, 1 reply; 5+ messages in thread
From: Ni, Ray @ 2020-09-11 18:37 UTC (permalink / raw)
  To: Dong, Eric, Chiu, Chasel, devel@edk2.groups.io
  Cc: Chiu, Chasel, Laszlo Ersek, Kumar, Rahul1, Desimone, Nathaniel L

[-- Attachment #1: Type: text/plain, Size: 8167 bytes --]

A rough check in phone. Why inf file is not changed?

________________________________
发件人: Dong, Eric <eric.dong@intel.com>
发送时间: Friday, September 11, 2020 10:31:32 AM
收件人: Chiu, Chasel <chasel.chiu@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>
抄送: Chiu, Chasel <chasel.chiu@intel.com>; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
主题: RE: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.

Reviewed-by: Eric Dong <eric.dong@intel.com>

-----Original Message-----
From: Chasel Chiu <chasel.chiu@intel.com>
Sent: Thursday, September 10, 2020 5:03 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.

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 <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 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/PeiRegisterCpuFeaturesLi
+++ b.c
@@ -1,7 +1,7 @@
 /** @file
   CPU Register Table Library functions.

-  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2020, Intel Corporation. All rights
+ reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent

 **/
@@ -11,7 +11,6 @@
 #include <Library/HobLib.h>
 #include <Library/PeiServicesLib.h>
 #include <Library/PeiServicesTablePointerLib.h>
-#include <Ppi/MpServices.h>
 #include <Ppi/MpServices2.h>

 #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 <PiPei.h>
 #include <PiDxe.h>
-#include <Ppi/MpServices.h>
+#include <Ppi/MpServices2.h>
 #include <Protocol/MpService.h>

 #include <Library/BaseLib.h>
@@ -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


[-- Attachment #2: Type: text/html, Size: 15228 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.
  2020-09-11 18:37   ` Ni, Ray
@ 2020-09-14  0:50     ` Chiu, Chasel
  0 siblings, 0 replies; 5+ messages in thread
From: Chiu, Chasel @ 2020-09-14  0:50 UTC (permalink / raw)
  To: Ni, Ray, Dong, Eric, devel@edk2.groups.io
  Cc: Laszlo Ersek, Kumar, Rahul1, Desimone, Nathaniel L

[-- Attachment #1: Type: text/plain, Size: 9484 bytes --]


Thanks Ray. This is good catch and it was no issue because both MpServices and MpServices2 at the same time.
I will update INF.

Thanks,
Chasel


From: Ni, Ray <ray.ni@intel.com>
Sent: Saturday, September 12, 2020 2:37 AM
To: Dong, Eric <eric.dong@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Subject: Re: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.

A rough check in phone. Why inf file is not changed?

________________________________
发件人: Dong, Eric <eric.dong@intel.com<mailto:eric.dong@intel.com>>
发送时间: Friday, September 11, 2020 10:31:32 AM
收件人: Chiu, Chasel <chasel.chiu@intel.com<mailto:chasel.chiu@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>
抄送: Chiu, Chasel <chasel.chiu@intel.com<mailto:chasel.chiu@intel.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Kumar, Rahul1 <rahul1.kumar@intel.com<mailto:rahul1.kumar@intel.com>>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com<mailto:nathaniel.l.desimone@intel.com>>
主题: RE: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.

Reviewed-by: Eric Dong <eric.dong@intel.com<mailto:eric.dong@intel.com>>

-----Original Message-----
From: Chasel Chiu <chasel.chiu@intel.com<mailto:chasel.chiu@intel.com>>
Sent: Thursday, September 10, 2020 5:03 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Chiu, Chasel <chasel.chiu@intel.com<mailto:chasel.chiu@intel.com>>; Dong, Eric <eric.dong@intel.com<mailto:eric.dong@intel.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Kumar, Rahul1 <rahul1.kumar@intel.com<mailto:rahul1.kumar@intel.com>>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com<mailto:nathaniel.l.desimone@intel.com>>
Subject: [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case.

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 <eric.dong@intel.com<mailto:eric.dong@intel.com>>
Cc: Ray Ni <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Cc: Rahul Kumar <rahul1.kumar@intel.com<mailto:rahul1.kumar@intel.com>>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com<mailto:nathaniel.l.desimone@intel.com>>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com<mailto:chasel.chiu@intel.com>>
---
 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/PeiRegisterCpuFeaturesLi
+++ b.c
@@ -1,7 +1,7 @@
 /** @file
   CPU Register Table Library functions.

-  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2020, Intel Corporation. All rights
+ reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent

 **/
@@ -11,7 +11,6 @@
 #include <Library/HobLib.h>
 #include <Library/PeiServicesLib.h>
 #include <Library/PeiServicesTablePointerLib.h>
-#include <Ppi/MpServices.h>
 #include <Ppi/MpServices2.h>

 #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 <PiPei.h>
 #include <PiDxe.h>
-#include <Ppi/MpServices.h>
+#include <Ppi/MpServices2.h>
 #include <Protocol/MpService.h>

 #include <Library/BaseLib.h>
@@ -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

[-- Attachment #2: Type: text/html, Size: 21778 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-14  0:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-10  9:02 [PATCH] UefiCpuPkg/RegisterCpuFeaturesLib: Support MpServices2 only case Chiu, Chasel
2020-09-10 11:03 ` Laszlo Ersek
2020-09-11  2:31 ` Dong, Eric
2020-09-11 18:37   ` Ni, Ray
2020-09-14  0:50     ` Chiu, Chasel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox