]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
UefiCpuPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / UefiCpuPkg / Library / RegisterCpuFeaturesLib / PeiRegisterCpuFeaturesLib.c
index a688e03152bd07a75b671d65a9a2f5772e85527c..2b1553f9b84b25db6aef84b76f2ad1bfdc594745 100644 (file)
@@ -2,13 +2,7 @@
   CPU Register Table Library functions.\r
 \r
   Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -68,15 +62,15 @@ GetCpuFeaturesData (
 /**\r
   Worker function to get MP PPI service pointer.\r
 \r
-  @return PEI PPI service pointer.\r
+  @return MP_SERVICES variable.\r
 **/\r
-EFI_PEI_MP_SERVICES_PPI *\r
-GetMpPpi (\r
+MP_SERVICES\r
+GetMpService (\r
   VOID\r
   )\r
 {\r
   EFI_STATUS                 Status;\r
-  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
+  MP_SERVICES                MpService;\r
 \r
   //\r
   // Get MP Services Protocol\r
@@ -85,29 +79,36 @@ GetMpPpi (
              &gEfiPeiMpServicesPpiGuid,\r
              0,\r
              NULL,\r
-             (VOID **)&CpuMpPpi\r
+             (VOID **)&MpService.Ppi\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
-  return CpuMpPpi;\r
+  return MpService;\r
 }\r
 \r
 /**\r
   Worker function to return processor index.\r
 \r
+  @param  CpuFeaturesData    Cpu Feature Data structure.\r
+\r
   @return  The processor index.\r
 **/\r
 UINTN\r
 GetProcessorIndex (\r
-  VOID\r
+  IN CPU_FEATURES_DATA        *CpuFeaturesData\r
   )\r
 {\r
   EFI_STATUS                 Status;\r
   EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
   UINTN                      ProcessorIndex;\r
 \r
-  CpuMpPpi = GetMpPpi ();\r
+  CpuMpPpi = CpuFeaturesData->MpService.Ppi;\r
 \r
-  Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex);\r
+  //\r
+  // For two reasons which use NULL for WhoAmI:\r
+  // 1. This function will be called by APs and AP should not use PeiServices Table\r
+  // 2. Check WhoAmI implementation, this parameter will not be used.\r
+  //\r
+  Status = CpuMpPpi->WhoAmI(NULL, CpuMpPpi, &ProcessorIndex);\r
   ASSERT_EFI_ERROR (Status);\r
   return ProcessorIndex;\r
 }\r
@@ -130,8 +131,11 @@ GetProcessorInformation (
 {\r
   EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
   EFI_STATUS                 Status;\r
+  CPU_FEATURES_DATA          *CpuFeaturesData;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  CpuMpPpi = CpuFeaturesData->MpService.Ppi;\r
 \r
-  CpuMpPpi = GetMpPpi ();\r
   Status = CpuMpPpi->GetProcessorInfo (\r
                GetPeiServicesTablePointer(),\r
                CpuMpPpi,\r
@@ -146,6 +150,8 @@ GetProcessorInformation (
 \r
   @param[in]  Procedure               A pointer to the function to be run on\r
                                       enabled APs of the system.\r
+  @param[in]  MpEvent                 The Event used to sync the result.\r
+\r
 **/\r
 VOID\r
 StartupAPsWorker (\r
@@ -158,17 +164,7 @@ StartupAPsWorker (
   CPU_FEATURES_DATA                    *CpuFeaturesData;\r
 \r
   CpuFeaturesData = GetCpuFeaturesData ();\r
-\r
-  //\r
-  // Get MP Services Protocol\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-             &gEfiPeiMpServicesPpiGuid,\r
-             0,\r
-             NULL,\r
-             (VOID **)&CpuMpPpi\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
+  CpuMpPpi = CpuFeaturesData->MpService.Ppi;\r
 \r
   //\r
   // Wakeup all APs for data collection.\r
@@ -196,17 +192,10 @@ SwitchNewBsp (
 {\r
   EFI_STATUS                           Status;\r
   EFI_PEI_MP_SERVICES_PPI              *CpuMpPpi;\r
+  CPU_FEATURES_DATA                    *CpuFeaturesData;\r
 \r
-  //\r
-  // Get MP Services Protocol\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-             &gEfiPeiMpServicesPpiGuid,\r
-             0,\r
-             NULL,\r
-             (VOID **)&CpuMpPpi\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  CpuMpPpi = CpuFeaturesData->MpService.Ppi;\r
 \r
   //\r
   // Wakeup all APs for data collection.\r
@@ -238,17 +227,10 @@ GetNumberOfProcessor (
 {\r
   EFI_STATUS                 Status;\r
   EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
+  CPU_FEATURES_DATA          *CpuFeaturesData;\r
 \r
-  //\r
-  // Get MP Services Protocol\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-             &gEfiPeiMpServicesPpiGuid,\r
-             0,\r
-             NULL,\r
-             (VOID **)&CpuMpPpi\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  CpuMpPpi = CpuFeaturesData->MpService.Ppi;\r
 \r
   //\r
   // Get the number of CPUs\r
@@ -281,7 +263,7 @@ CpuFeaturesInitialize (
 \r
   CpuFeaturesData = GetCpuFeaturesData ();\r
 \r
-  OldBspNumber = GetProcessorIndex();\r
+  OldBspNumber = GetProcessorIndex (CpuFeaturesData);\r
   CpuFeaturesData->BspNumber = OldBspNumber;\r
 \r
   //\r