public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jeff Fan <jeff.fan@intel.com>
To: edk2-devel@lists.01.org
Cc: Michael Kinney <michael.d.kinney@intel.com>,
	Feng Tian <feng.tian@intel.com>,
	Giri P Mudusuru <giri.p.mudusuru@intel.com>
Subject: [Patch 4/7] UefiCpuPkg/CpuMpPei: Build GUIDed-HOB to store all CPU BIST Data
Date: Fri,  9 Sep 2016 15:59:30 +0800	[thread overview]
Message-ID: <20160909075933.14320-5-jeff.fan@intel.com> (raw)
In-Reply-To: <20160909075933.14320-1-jeff.fan@intel.com>

Build gEfiSecPlatformInformation2PpiGuid GUIDed-HOB to store all CPU BIST data
that could be used not only by SecPlatformInformation2(), but also by CPU MP Dxe
driver to get CPU BIST data.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
 UefiCpuPkg/CpuMpPei/CpuBist.c    | 64 ++++++++++++++++++++++++++--------------
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   |  1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  4 ++-
 3 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c
index f596237..bf18ca4 100644
--- a/UefiCpuPkg/CpuMpPei/CpuBist.c
+++ b/UefiCpuPkg/CpuMpPei/CpuBist.c
@@ -44,34 +44,29 @@ SecPlatformInformation2 (
      OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
   )
 {
-  UINTN                                BistInformationSize;
-  UINTN                                CpuIndex;
-  EFI_SEC_PLATFORM_INFORMATION_CPU     *CpuInstance;
-  EFI_PROCESSOR_INFORMATION            ProcessorInfo;
-  EFI_HEALTH_FLAGS                     BistData;
-  UINTN                                NumberOfProcessors;
-  UINTN                                NumberOfEnabledProcessors;
+  EFI_HOB_GUID_TYPE       *GuidHob;
+  VOID                    *DataInHob;
+  UINTN                   DataSize;
 
-  MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);
+  GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);
+  if (GuidHob == NULL) {
+    *StructureSize = 0;
+    return EFI_SUCCESS;
+  }
+
+  DataInHob = GET_GUID_HOB_DATA (GuidHob);
+  DataSize  = GET_GUID_HOB_DATA_SIZE (GuidHob);
 
-  BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) +
-                        sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors;
   //
-  // return the information size if input buffer size is too small
+  // return the information from BistHob
   //
-  if ((*StructureSize) < (UINT64) BistInformationSize) {
-    *StructureSize = (UINT64) BistInformationSize;
+  if ((*StructureSize) < (UINT64) DataSize) {
+    *StructureSize = (UINT64) DataSize;
     return EFI_BUFFER_TOO_SMALL;
   }
 
-  PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;
-  CpuInstance = PlatformInformationRecord2->CpuInstance;
-  for (CpuIndex = 0; CpuIndex < NumberOfProcessors; CpuIndex ++) {
-    MpInitLibGetProcessorInfo (CpuIndex, &ProcessorInfo, &BistData);
-    CpuInstance[CpuIndex].CpuLocation = (UINT32) ProcessorInfo.ProcessorId;
-    CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags = BistData;
-  }
-
+  *StructureSize = (UINT64) DataSize;
+  CopyMem (PlatformInformationRecord2, DataInHob, DataSize);
   return EFI_SUCCESS;
 }
 
@@ -181,14 +176,26 @@ CollectBistDataFromPpi (
   EFI_HEALTH_FLAGS                      BistData;
   UINTN                                 NumberOfProcessors;
   UINTN                                 NumberOfEnabledProcessors;
+  UINTN                                 BistInformationSize;
+  EFI_SEC_PLATFORM_INFORMATION_RECORD2  *PlatformInformationRecord2;
+  EFI_SEC_PLATFORM_INFORMATION_CPU      *CpuInstanceInHob;
+  
 
   MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);
 
+  BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) +
+                        sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors;
+  Status = PeiServicesAllocatePool (
+             (UINTN) BistInformationSize,
+             (VOID **) &PlatformInformationRecord2
+             );
+  ASSERT_EFI_ERROR (Status);
+  PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;
+
   SecPlatformInformation2 = NULL;
   SecPlatformInformation  = NULL;
   NumberOfData            = 0;
   CpuInstance             = NULL;
-
   //
   // Get BIST information from Sec Platform Information2 Ppi firstly
   //
@@ -253,7 +260,20 @@ CollectBistDataFromPpi (
             (UINT32) ProcessorInfo.ProcessorId,
             BistData
             ));
+    CpuInstanceInHob = PlatformInformationRecord2->CpuInstance;
+    CpuInstanceInHob[ProcessorNumber].CpuLocation = (UINT32) ProcessorInfo.ProcessorId;
+    CpuInstanceInHob[ProcessorNumber].InfoRecord.IA32HealthFlags = BistData;
   }
+ 
+  //
+  // Build SecPlatformInformation2 PPI GUIDed HOB that also could be consumed
+  // by CPU MP driver to get CPU BIST data
+  //
+  BuildGuidDataHob (
+    &gEfiSecPlatformInformation2PpiGuid,
+    PlatformInformationRecord2,
+    (UINTN) BistInformationSize
+    );
 
   if (SecPlatformInformation2 != NULL && NumberOfData < NumberOfProcessors) {
     //
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 24931c9..0836593 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -31,6 +31,7 @@
 #include <Library/ReportStatusCodeLib.h>
 #include <Library/CpuExceptionHandlerLib.h>
 #include <Library/MpInitLib.h>
+#include <Library/BaseMemoryLib.h>
 
 extern EFI_PEI_PPI_DESCRIPTOR   mPeiCpuMpPpiDesc;
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index c8461a2..3b40d88 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -47,12 +47,14 @@ [LibraryClasses]
   ReportStatusCodeLib
   CpuExceptionHandlerLib
   MpInitLib
+  BaseMemoryLib
 
 [Ppis]
   gEfiPeiMpServicesPpiGuid                      ## PRODUCES
   gEfiSecPlatformInformationPpiGuid             ## SOMETIMES_CONSUMES
   ## SOMETIMES_CONSUMES
-  ## SOMETIMES_PRODUCES
+  ## PRODUCES
+  ## UNDEFINED # HOB
   gEfiSecPlatformInformation2PpiGuid
   gEfiVectorHandoffInfoPpiGuid                  ## SOMETIMES_CONSUMES
 
-- 
2.9.3.windows.2



  parent reply	other threads:[~2016-09-09  8:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09  7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
2016-09-09  7:59 ` [Patch 1/7] UefiCpuPkg/CpuDxe: Fix duplicated status code report Jeff Fan
2016-09-09  7:59 ` [Patch 2/7] UefiCpuPkg/CpuMpPei: Add parameter BistInformationSize Jeff Fan
2016-09-09  7:59 ` [Patch 3/7] UefiCpuPkg/CpuMpPei: Fix BistData ouput error Jeff Fan
2016-09-09  7:59 ` Jeff Fan [this message]
2016-09-09  7:59 ` [Patch 5/7] UefiCpuPkg/SecCore: Add SecBist.c Jeff Fan
2016-09-09  7:59 ` [Patch 6/7] UefiCpuPkg/SecCore: Abstract worker function GetBistFromHob() Jeff Fan
2016-09-09  7:59 ` [Patch 7/7] UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI Jeff Fan
2016-09-13  7:41 ` [Patch 0/7] Re-install SEC Platform Information PPI Tian, Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160909075933.14320-5-jeff.fan@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox