]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuMpPei/CpuBist.c
UefiCpuPkg/CpuMpPei: Fix BistData ouput error
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / CpuBist.c
index 56292452a9c786d8741c9a33a259d05d4957c2d0..f596237890511abc0d00edbacdcb863882a053a8 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
@@ -80,6 +84,7 @@ SecPlatformInformation2 (
   @param  PpiDescriptor       Return a pointer to instance of the\r
                               EFI_PEI_PPI_DESCRIPTOR\r
   @param  BistInformationData Pointer to BIST information data\r
+  @param  BistInformationSize Return the size in bytes of BIST information\r
 \r
   @retval EFI_SUCCESS         Retrieve of the BIST data successfully\r
   @retval EFI_NOT_FOUND       No sec platform information(2) ppi export\r
@@ -91,7 +96,8 @@ GetBistInfoFromPpi (
   IN CONST EFI_PEI_SERVICES     **PeiServices,\r
   IN CONST EFI_GUID             *Guid,\r
      OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
-     OUT VOID                   **BistInformationData\r
+     OUT VOID                   **BistInformationData,\r
+     OUT UINT64                 *BistInformationSize OPTIONAL\r
   )\r
 {\r
   EFI_STATUS                            Status;\r
@@ -136,6 +142,9 @@ GetBistInfoFromPpi (
                                                );\r
         if (Status == EFI_SUCCESS) {\r
           *BistInformationData = SecPlatformInformation2;\r
+          if (BistInformationSize != NULL) {\r
+            *BistInformationSize = InformationSize;\r
+          }\r
           return EFI_SUCCESS;\r
         }\r
       }\r
@@ -152,13 +161,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 +177,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
@@ -184,7 +196,8 @@ CollectBistDataFromPpi (
              PeiServices,\r
              &gEfiSecPlatformInformation2PpiGuid,\r
              &SecInformationDescriptor,\r
-             (VOID *) &SecPlatformInformation2\r
+             (VOID *) &SecPlatformInformation2,\r
+             NULL\r
              );\r
   if (Status == EFI_SUCCESS) {\r
     //\r
@@ -200,7 +213,8 @@ CollectBistDataFromPpi (
                PeiServices,\r
                &gEfiSecPlatformInformationPpiGuid,\r
                &SecInformationDescriptor,\r
-               (VOID *) &SecPlatformInformation\r
+               (VOID *) &SecPlatformInformation,\r
+               NULL\r
                );\r
     if (Status == EFI_SUCCESS) {\r
       NumberOfData = 1;\r
@@ -215,21 +229,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 +250,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
+            (UINT32) 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 +266,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