]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuMpPei/CpuBist.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / CpuBist.c
index 5312d9f01dc8229aa601112e5b471d60d162ddca..7dc93cd784d4ae01774ad3b252fc8292a6a329f1 100644 (file)
@@ -2,23 +2,17 @@
   Update and publish processors' BIST information.\r
 \r
   Copyright (c) 2015 - 2018, 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
 #include "CpuMpPei.h"\r
 \r
-EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2Ppi = {\r
+EFI_SEC_PLATFORM_INFORMATION2_PPI  mSecPlatformInformation2Ppi = {\r
   SecPlatformInformation2\r
 };\r
 \r
-EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2Ppi = {\r
+EFI_PEI_PPI_DESCRIPTOR  mPeiSecPlatformInformation2Ppi = {\r
   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
   &gEfiSecPlatformInformation2PpiGuid,\r
   &mSecPlatformInformation2Ppi\r
@@ -39,14 +33,14 @@ EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2Ppi = {
 EFI_STATUS\r
 EFIAPI\r
 SecPlatformInformation2 (\r
-  IN CONST EFI_PEI_SERVICES                   **PeiServices,\r
-  IN OUT UINT64                               *StructureSize,\r
-     OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2\r
+  IN CONST EFI_PEI_SERVICES                 **PeiServices,\r
+  IN OUT UINT64                             *StructureSize,\r
+  OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2  *PlatformInformationRecord2\r
   )\r
 {\r
-  EFI_HOB_GUID_TYPE       *GuidHob;\r
-  VOID                    *DataInHob;\r
-  UINTN                   DataSize;\r
+  EFI_HOB_GUID_TYPE  *GuidHob;\r
+  VOID               *DataInHob;\r
+  UINTN              DataSize;\r
 \r
   GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);\r
   if (GuidHob == NULL) {\r
@@ -60,12 +54,12 @@ SecPlatformInformation2 (
   //\r
   // return the information from BistHob\r
   //\r
-  if ((*StructureSize) < (UINT64) DataSize) {\r
-    *StructureSize = (UINT64) DataSize;\r
+  if ((*StructureSize) < (UINT64)DataSize) {\r
+    *StructureSize = (UINT64)DataSize;\r
     return EFI_BUFFER_TOO_SMALL;\r
   }\r
 \r
-  *StructureSize = (UINT64) DataSize;\r
+  *StructureSize = (UINT64)DataSize;\r
   CopyMem (PlatformInformationRecord2, DataInHob, DataSize);\r
   return EFI_SUCCESS;\r
 }\r
@@ -88,11 +82,11 @@ SecPlatformInformation2 (
 **/\r
 EFI_STATUS\r
 GetBistInfoFromPpi (\r
-  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 UINT64                 *BistInformationSize OPTIONAL\r
+  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 UINT64                  *BistInformationSize OPTIONAL\r
   )\r
 {\r
   EFI_STATUS                            Status;\r
@@ -116,15 +110,15 @@ GetBistInfoFromPpi (
     //\r
     InformationSize         = 0;\r
     SecPlatformInformation2 = NULL;\r
-    Status = SecPlatformInformation2Ppi->PlatformInformation2 (\r
-                                           PeiServices,\r
-                                           &InformationSize,\r
-                                           SecPlatformInformation2\r
-                                           );\r
+    Status                  = SecPlatformInformation2Ppi->PlatformInformation2 (\r
+                                                            PeiServices,\r
+                                                            &InformationSize,\r
+                                                            SecPlatformInformation2\r
+                                                            );\r
     if (Status == EFI_BUFFER_TOO_SMALL) {\r
       Status = PeiServicesAllocatePool (\r
-                 (UINTN) InformationSize,\r
-                 (VOID **) &SecPlatformInformation2\r
+                 (UINTN)InformationSize,\r
+                 (VOID **)&SecPlatformInformation2\r
                  );\r
       if (Status == EFI_SUCCESS) {\r
         //\r
@@ -140,6 +134,7 @@ GetBistInfoFromPpi (
           if (BistInformationSize != NULL) {\r
             *BistInformationSize = InformationSize;\r
           }\r
+\r
           return EFI_SUCCESS;\r
         }\r
       }\r
@@ -160,7 +155,7 @@ GetBistInfoFromPpi (
 **/\r
 VOID\r
 CollectBistDataFromPpi (\r
-  IN CONST EFI_PEI_SERVICES             **PeiServices\r
+  IN CONST EFI_PEI_SERVICES  **PeiServices\r
   )\r
 {\r
   EFI_STATUS                            Status;\r
@@ -180,14 +175,13 @@ CollectBistDataFromPpi (
   EFI_SEC_PLATFORM_INFORMATION_RECORD2  *PlatformInformationRecord2;\r
   EFI_SEC_PLATFORM_INFORMATION_CPU      *CpuInstanceInHob;\r
 \r
-\r
-  MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);\r
+  MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors);\r
 \r
   BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) +\r
                         sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors;\r
   Status = PeiServicesAllocatePool (\r
-             (UINTN) BistInformationSize,\r
-             (VOID **) &PlatformInformationRecord2\r
+             (UINTN)BistInformationSize,\r
+             (VOID **)&PlatformInformationRecord2\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
   PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;\r
@@ -203,7 +197,7 @@ CollectBistDataFromPpi (
              PeiServices,\r
              &gEfiSecPlatformInformation2PpiGuid,\r
              &SecInformationDescriptor,\r
-             (VOID *) &SecPlatformInformation2,\r
+             (VOID *)&SecPlatformInformation2,\r
              NULL\r
              );\r
   if (Status == EFI_SUCCESS) {\r
@@ -220,7 +214,7 @@ CollectBistDataFromPpi (
                PeiServices,\r
                &gEfiSecPlatformInformationPpiGuid,\r
                &SecInformationDescriptor,\r
-               (VOID *) &SecPlatformInformation,\r
+               (VOID *)&SecPlatformInformation,\r
                NULL\r
                );\r
     if (Status == EFI_SUCCESS) {\r
@@ -229,16 +223,17 @@ CollectBistDataFromPpi (
       // SEC Platform Information only includes BSP's BIST information\r
       // and does not have BSP's APIC ID\r
       //\r
-      BspCpuInstance.CpuLocation = GetInitialApicId ();\r
-      BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32  = SecPlatformInformation->IA32HealthFlags.Uint32;\r
-      CpuInstance = &BspCpuInstance;\r
+      BspCpuInstance.CpuLocation                       = GetInitialApicId ();\r
+      BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32 = SecPlatformInformation->IA32HealthFlags.Uint32;\r
+      CpuInstance                                      = &BspCpuInstance;\r
     } else {\r
-      DEBUG ((EFI_D_INFO, "Does not find any stored CPU BIST information from PPI!\n"));\r
+      DEBUG ((DEBUG_INFO, "Does not find any stored CPU BIST information from PPI!\n"));\r
     }\r
   }\r
-  for (ProcessorNumber = 0; ProcessorNumber < NumberOfProcessors; ProcessorNumber ++) {\r
+\r
+  for (ProcessorNumber = 0; ProcessorNumber < NumberOfProcessors; ProcessorNumber++) {\r
     MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData);\r
-    for (CpuIndex = 0; CpuIndex < NumberOfData; CpuIndex ++) {\r
+    for (CpuIndex = 0; CpuIndex < NumberOfData; CpuIndex++) {\r
       ASSERT (CpuInstance != NULL);\r
       if (ProcessorInfo.ProcessorId == CpuInstance[CpuIndex].CpuLocation) {\r
         //\r
@@ -247,6 +242,7 @@ CollectBistDataFromPpi (
         BistData = CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags;\r
       }\r
     }\r
+\r
     if (BistData.Uint32 != 0) {\r
       //\r
       // Report Status Code that self test is failed\r
@@ -256,12 +252,15 @@ CollectBistDataFromPpi (
         (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST)\r
         );\r
     }\r
-    DEBUG ((EFI_D_INFO, "  APICID - 0x%08x, BIST - 0x%08x\n",\r
-            (UINT32) ProcessorInfo.ProcessorId,\r
-            BistData\r
-            ));\r
-    CpuInstanceInHob = PlatformInformationRecord2->CpuInstance;\r
-    CpuInstanceInHob[ProcessorNumber].CpuLocation = (UINT32) ProcessorInfo.ProcessorId;\r
+\r
+    DEBUG ((\r
+      DEBUG_INFO,\r
+      "  APICID - 0x%08x, BIST - 0x%08x\n",\r
+      (UINT32)ProcessorInfo.ProcessorId,\r
+      BistData\r
+      ));\r
+    CpuInstanceInHob                                             = PlatformInformationRecord2->CpuInstance;\r
+    CpuInstanceInHob[ProcessorNumber].CpuLocation                = (UINT32)ProcessorInfo.ProcessorId;\r
     CpuInstanceInHob[ProcessorNumber].InfoRecord.IA32HealthFlags = BistData;\r
   }\r
 \r
@@ -272,7 +271,7 @@ CollectBistDataFromPpi (
   BuildGuidDataHob (\r
     &gEfiSecPlatformInformation2PpiGuid,\r
     PlatformInformationRecord2,\r
-    (UINTN) BistInformationSize\r
+    (UINTN)BistInformationSize\r
     );\r
 \r
   if (SecPlatformInformation2 != NULL) {\r
@@ -291,7 +290,6 @@ CollectBistDataFromPpi (
     // Install SecPlatformInformation2 PPI\r
     //\r
     Status = PeiServicesInstallPpi (&mPeiSecPlatformInformation2Ppi);\r
-    ASSERT_EFI_ERROR(Status);\r
+    ASSERT_EFI_ERROR (Status);\r
   }\r
 }\r
-\r