Reviewed-by: Feng Tian <feng.t...@intel.com>

-----Original Message-----
From: Fan, Jeff 
Sent: Thursday, June 11, 2015 16:51
To: edk2-devel@lists.sourceforge.net
Cc: Tian, Feng
Subject: [Patch 3/3] UefiCpuPkg/CpuDxe: Get CPU BIST information from Guided HOB

Get CPU BIST information from gEfiSecPlatformInformation2PpiGuid or 
gEfiSecPlatformInformationPpiGuid Guided HOB and update the CPU healthy status 
for CPU MP Service.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff....@intel.com>
CC: Feng Tian <feng.t...@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.inf |  8 +++-
 UefiCpuPkg/CpuDxe/CpuMp.c    | 90 +++++++++++++++++++++++++++++++++++++++++++-
 UefiCpuPkg/CpuDxe/CpuMp.h    |  6 ++-
 3 files changed, 101 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf index 
61bc55a..a251922 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.inf
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Simple CPU driver installs CPU Architecture Protocol.
 #
-#  Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2008 - 2015, Intel Corporation. All rights 
+reserved.<BR>
 #  This program and the accompanying materials  #  are licensed and made 
available under the terms and conditions of the BSD License  #  which 
accompanies this distribution.  The full text of the license may be found at @@ 
-43,6 +43,8 @@
   CpuExceptionHandlerLib
   TimerLib
   SynchronizationLib
+  HobLib
+  ReportStatusCodeLib
 
 [Sources]
   ApStartup.c
@@ -77,6 +79,10 @@
   gIdleLoopEventGuid                            ## CONSUMES           ## Event
   gEfiVectorHandoffTableGuid                    ## SOMETIMES_CONSUMES ## 
SystemTable
 
+[Ppis]
+  gEfiSecPlatformInformation2PpiGuid            ## UNDEFINED # HOB
+  gEfiSecPlatformInformationPpiGuid             ## UNDEFINED # HOB
+
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber   ## CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize                 ## CONSUMES
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index 
fa0ef37..41bf504 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1,7 +1,7 @@
 /** @file
   CPU DXE Module.
 
-  Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2008 - 2015, Intel Corporation. All rights 
+ reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at @@ -1521,6 +1521,89 @@ InitMpSystemData (  }
 
 /**
+  Collects BIST data from HOB.
+
+  This function collects BIST data from HOB built from Sec Platform 
+ Information  PPI or SEC Platform Information2 PPI.
+
+**/
+VOID
+CollectBistDataFromHob (
+  VOID
+  )
+{
+  EFI_HOB_GUID_TYPE                     *GuidHob;
+  EFI_SEC_PLATFORM_INFORMATION_RECORD2  *SecPlatformInformation2;
+  EFI_SEC_PLATFORM_INFORMATION_RECORD   *SecPlatformInformation;
+  UINTN                                 NumberOfData;
+  EFI_SEC_PLATFORM_INFORMATION_CPU      *CpuInstance;
+  EFI_SEC_PLATFORM_INFORMATION_CPU      BspCpuInstance;
+  UINTN                                 ProcessorNumber;
+  UINT32                                InitialLocalApicId;
+  CPU_DATA_BLOCK                        *CpuData;
+
+  SecPlatformInformation2 = NULL;
+  SecPlatformInformation  = NULL;
+
+  //
+  // Get gEfiSecPlatformInformation2PpiGuid Guided HOB firstly  //  
+ GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);
+  if (GuidHob != NULL) {
+    //
+    // Sec Platform Information2 PPI includes BSP/APs' BIST information
+    //
+    SecPlatformInformation2 = GET_GUID_HOB_DATA (GuidHob);
+    NumberOfData = SecPlatformInformation2->NumberOfCpus;
+    CpuInstance  = SecPlatformInformation2->CpuInstance;
+  } else {
+    //
+    // Otherwise, get gEfiSecPlatformInformationPpiGuid Guided HOB
+    //
+    GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid);
+    if (GuidHob != NULL) {
+      SecPlatformInformation = GET_GUID_HOB_DATA (GuidHob);
+      NumberOfData = 1;
+      //
+      // SEC Platform Information only includes BSP's BIST information
+      // does not have BSP's APIC ID
+      //
+      BspCpuInstance.CpuLocation = GetApicId ();
+      BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32  = 
SecPlatformInformation->IA32HealthFlags.Uint32;
+      CpuInstance = &BspCpuInstance;
+    } else {
+      DEBUG ((EFI_D_INFO, "Does not find any HOB stored CPU BIST 
information!\n"));
+      //
+      // Does not find any HOB stored BIST information
+      //
+      return;
+    }
+  }
+
+  while (NumberOfData--) {
+    for (ProcessorNumber = 0; ProcessorNumber < 
mMpSystemData.NumberOfProcessors; ProcessorNumber++) {
+      CpuData = &mMpSystemData.CpuDatas[ProcessorNumber];
+      InitialLocalApicId = (UINT32) CpuData->Info.ProcessorId;
+      if (InitialLocalApicId == CpuInstance[NumberOfData].CpuLocation) {
+        //
+        // Update CPU health status for MP Services Protocol according to BIST 
data.
+        //
+        if (CpuInstance[NumberOfData].InfoRecord.IA32HealthFlags.Uint32 != 0) {
+          CpuData->Info.StatusFlag &= ~PROCESSOR_HEALTH_STATUS_BIT;
+          //
+          // Report Status Code that self test is failed
+          //
+          REPORT_STATUS_CODE (
+            EFI_ERROR_CODE | EFI_ERROR_MAJOR,
+            (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST)
+            );        
+        }
+      }
+    }
+  }
+}
+
+/**
   Callback function for ExitBootServices.
 
   @param  Event                 Event whose notification function is being 
invoked.
@@ -1597,6 +1680,11 @@ InitializeMpSupport (
 
   mAPsAlreadyInitFinished = TRUE;
 
+  //
+  // Update CPU healthy information from Guided HOB  //  
+ CollectBistDataFromHob ();
+
   Status = gBS->InstallMultipleProtocolInterfaces (
                   &mMpServiceHandle,
                   &gEfiMpServiceProtocolGuid,  &mMpServicesTemplate, diff 
--git a/UefiCpuPkg/CpuDxe/CpuMp.h b/UefiCpuPkg/CpuDxe/CpuMp.h index 
021b808..d2866e4 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.h
+++ b/UefiCpuPkg/CpuDxe/CpuMp.h
@@ -1,7 +1,7 @@
 /** @file
   CPU DXE MP support
 
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2015, Intel Corporation. All rights 
+ reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at @@ -15,8 +15,12 @@  #ifndef _CPU_MP_H_  #define _CPU_MP_H_
 
+#include <Ppi/SecPlatformInformation.h> #include 
+<Ppi/SecPlatformInformation2.h>
 #include <Protocol/MpService.h>
 #include <Library/SynchronizationLib.h>
+#include <Library/HobLib.h>
+#include <Library/ReportStatusCodeLib.h>
 
 /**
   Initialize Multi-processor support.
--
1.9.5.msysgit.0


------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to