]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuMpPei/CpuBist.c
UefiCpuPkg/CpuMpPei: Consume MpInitLib to produce CPU MP PPI services
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / CpuBist.c
index 56292452a9c786d8741c9a33a259d05d4957c2d0..641eb10ca5809fba555963c7d9391f1a641b78b5 100644 (file)
@@ -44,15 +44,18 @@ SecPlatformInformation2 (
      OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2\r
   )\r
 {\r
-  PEI_CPU_MP_DATA                      *PeiCpuMpData;\r
   UINTN                                BistInformationSize;\r
   UINTN                                CpuIndex;\r
   EFI_SEC_PLATFORM_INFORMATION_CPU     *CpuInstance;\r
+  EFI_PROCESSOR_INFORMATION            ProcessorInfo;\r
+  EFI_HEALTH_FLAGS                     BistData;\r
+  UINTN                                NumberOfProcessors;\r
+  UINTN                                NumberOfEnabledProcessors;\r
 \r
-  PeiCpuMpData = GetMpHobData ();\r
+  MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);\r
 \r
   BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) +\r
-                        sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * PeiCpuMpData->CpuCount;\r
+                        sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors;\r
   //\r
   // return the information size if input buffer size is too small\r
   //\r
@@ -61,11 +64,12 @@ SecPlatformInformation2 (
     return EFI_BUFFER_TOO_SMALL;\r
   }\r
 \r
-  PlatformInformationRecord2->NumberOfCpus = PeiCpuMpData->CpuCount;\r
+  PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;\r
   CpuInstance = PlatformInformationRecord2->CpuInstance;\r
-  for (CpuIndex = 0; CpuIndex < PeiCpuMpData->CpuCount; CpuIndex ++) {\r
-    CpuInstance[CpuIndex].CpuLocation                = PeiCpuMpData->CpuData[CpuIndex].ApicId;\r
-    CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags = PeiCpuMpData->CpuData[CpuIndex].Health;\r
+  for (CpuIndex = 0; CpuIndex < NumberOfProcessors; CpuIndex ++) {\r
+    MpInitLibGetProcessorInfo (CpuIndex, &ProcessorInfo, &BistData);\r
+    CpuInstance[CpuIndex].CpuLocation = (UINT32) ProcessorInfo.ProcessorId;\r
+    CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags = BistData;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -152,13 +156,11 @@ GetBistInfoFromPpi (
   or SEC Platform Information PPI.\r
 \r
   @param PeiServices         Pointer to PEI Services Table\r
-  @param PeiCpuMpData        Pointer to PEI CPU MP Data\r
 \r
 **/\r
 VOID\r
 CollectBistDataFromPpi (\r
-  IN CONST EFI_PEI_SERVICES             **PeiServices,\r
-  IN PEI_CPU_MP_DATA                    *PeiCpuMpData\r
+  IN CONST EFI_PEI_SERVICES             **PeiServices\r
   )\r
 {\r
   EFI_STATUS                            Status;\r
@@ -170,7 +172,12 @@ CollectBistDataFromPpi (
   EFI_SEC_PLATFORM_INFORMATION_CPU      BspCpuInstance;\r
   UINTN                                 ProcessorNumber;\r
   UINTN                                 CpuIndex;\r
-  PEI_CPU_DATA                          *CpuData;\r
+  EFI_PROCESSOR_INFORMATION             ProcessorInfo;\r
+  EFI_HEALTH_FLAGS                      BistData;\r
+  UINTN                                 NumberOfProcessors;\r
+  UINTN                                 NumberOfEnabledProcessors;\r
+\r
+  MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);\r
 \r
   SecPlatformInformation2 = NULL;\r
   SecPlatformInformation  = NULL;\r
@@ -215,21 +222,18 @@ CollectBistDataFromPpi (
       DEBUG ((EFI_D_INFO, "Does not find any stored CPU BIST information from PPI!\n"));\r
     }\r
   }\r
-  for (ProcessorNumber = 0; ProcessorNumber < PeiCpuMpData->CpuCount; ProcessorNumber ++) {\r
-    CpuData = &PeiCpuMpData->CpuData[ProcessorNumber];\r
+  for (ProcessorNumber = 0; ProcessorNumber < NumberOfProcessors; ProcessorNumber ++) {\r
+    MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData);\r
     for (CpuIndex = 0; CpuIndex < NumberOfData; CpuIndex ++) {\r
       ASSERT (CpuInstance != NULL);\r
-      if (CpuData->ApicId == CpuInstance[CpuIndex].CpuLocation) {\r
+      if (ProcessorInfo.ProcessorId == CpuInstance[CpuIndex].CpuLocation) {\r
         //\r
         // Update processor's BIST data if it is already stored before\r
         //\r
-        CpuData->Health = CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags;\r
+        BistData = CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags;\r
       }\r
     }\r
-    if (CpuData->Health.Uint32 == 0) {\r
-      CpuData->CpuHealthy = TRUE;\r
-    } else {\r
-      CpuData->CpuHealthy = FALSE;\r
+    if (BistData.Uint32 != 0) {\r
       //\r
       // Report Status Code that self test is failed\r
       //\r
@@ -239,14 +243,14 @@ CollectBistDataFromPpi (
         );\r
     }\r
     DEBUG ((EFI_D_INFO, "  APICID - 0x%08x, BIST - 0x%08x\n",\r
-            PeiCpuMpData->CpuData[ProcessorNumber].ApicId,\r
-            PeiCpuMpData->CpuData[ProcessorNumber].Health.Uint32\r
+            ProcessorInfo.ProcessorId,\r
+            BistData\r
             ));\r
   }\r
 \r
-  if (SecPlatformInformation2 != NULL && NumberOfData < PeiCpuMpData->CpuCount) {\r
+  if (SecPlatformInformation2 != NULL && NumberOfData < NumberOfProcessors) {\r
     //\r
-    // Reinstall SecPlatformInformation2 PPI to include new BIST inforamtion\r
+    // Reinstall SecPlatformInformation2 PPI to include new BIST information\r
     //\r
     Status = PeiServicesReInstallPpi (\r
                SecInformationDescriptor,\r
@@ -255,9 +259,10 @@ CollectBistDataFromPpi (
     ASSERT_EFI_ERROR (Status);\r
   } else {\r
     //\r
-    // Install SecPlatformInformation2 PPI to include new BIST inforamtion\r
+    // Install SecPlatformInformation2 PPI to include new BIST information\r
     //\r
     Status = PeiServicesInstallPpi (&mPeiSecPlatformInformation2Ppi);\r
     ASSERT_EFI_ERROR(Status);\r
   }\r
 }\r
+\r