소스 검색

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>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Chasel Chiu 3 년 전
부모
커밋
1b461403ee

+ 23 - 38
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
                          );

+ 2 - 3
UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf

@@ -1,7 +1,7 @@
 ## @file
 #  Register CPU Features Library PEI instance.
 #
-#  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR>
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -45,7 +45,6 @@
   IoLib
 
 [Ppis]
-  gEfiPeiMpServicesPpiGuid                                             ## CONSUMES
   gEdkiiPeiMpServices2PpiGuid                                          ## CONSUMES
 
 [Pcd]
@@ -55,4 +54,4 @@
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## CONSUMES ## PRODUCES
 
 [Depex]
-  gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid
+  gEdkiiPeiMpServices2PpiGuid AND gEdkiiCpuFeaturesSetDoneGuid

+ 3 - 3
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 {