]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/SecCore: Add SecBist.c
authorJeff Fan <jeff.fan@intel.com>
Fri, 9 Sep 2016 07:00:30 +0000 (15:00 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 14 Sep 2016 00:54:39 +0000 (08:54 +0800)
Add SecBist.c and copy GetBistInfoFromPpi() and SecPlatformInformation2() from
UefiCpuPkg/CpuMpPei/CpuBist.c. And update SecMain.c, SecMain.inf and
UefiCpuPkg.dsc accordinlgy to pass build.

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>
Reviewed-by: Feng Tian <feng.tian@Intel.com>
UefiCpuPkg/SecCore/SecBist.c [new file with mode: 0644]
UefiCpuPkg/SecCore/SecCore.inf
UefiCpuPkg/SecCore/SecMain.h
UefiCpuPkg/UefiCpuPkg.dsc

diff --git a/UefiCpuPkg/SecCore/SecBist.c b/UefiCpuPkg/SecCore/SecBist.c
new file mode 100644 (file)
index 0000000..cba445d
--- /dev/null
@@ -0,0 +1,140 @@
+/** @file\r
+  Get SEC platform information(2) PPI and reinstall it.\r
+\r
+  Copyright (c) 2006 - 2016, 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
+\r
+**/\r
+\r
+#include "SecMain.h"\r
+\r
+/**\r
+  Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.\r
+\r
+  @param  PeiServices                The pointer to the PEI Services Table.\r
+  @param  StructureSize              The pointer to the variable describing size of the input buffer.\r
+  @param  PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.\r
+\r
+  @retval EFI_SUCCESS                The data was successfully returned.\r
+  @retval EFI_BUFFER_TOO_SMALL       The buffer was too small. The current buffer size needed to\r
+                                     hold the record is returned in StructureSize.\r
+\r
+**/\r
+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
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE       *GuidHob;\r
+  VOID                    *DataInHob;\r
+  UINTN                   DataSize;\r
+\r
+  GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);\r
+  if (GuidHob == NULL) {\r
+    *StructureSize = 0;\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  DataInHob = GET_GUID_HOB_DATA (GuidHob);\r
+  DataSize  = GET_GUID_HOB_DATA_SIZE (GuidHob);\r
+\r
+  //\r
+  // return the information from BistHob\r
+  //\r
+  if ((*StructureSize) < (UINT64) DataSize) {\r
+    *StructureSize = (UINT64) DataSize;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  *StructureSize = (UINT64) DataSize;\r
+  CopyMem (PlatformInformationRecord2, DataInHob, DataSize);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Worker function to get CPUs' BIST by calling SecPlatformInformationPpi\r
+  or SecPlatformInformation2Ppi.\r
+\r
+  @param  PeiServices         Pointer to PEI Services Table\r
+  @param  Guid                PPI Guid\r
+  @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
+  @retval EFI_DEVICE_ERROR    Failed to get CPU Information\r
+\r
+**/\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
+  )\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_SEC_PLATFORM_INFORMATION2_PPI     *SecPlatformInformation2Ppi;\r
+  EFI_SEC_PLATFORM_INFORMATION_RECORD2  *SecPlatformInformation2;\r
+  UINT64                                InformationSize;\r
+\r
+  Status = PeiServicesLocatePpi (\r
+             Guid,                                // GUID\r
+             0,                                   // INSTANCE\r
+             PpiDescriptor,                       // EFI_PEI_PPI_DESCRIPTOR\r
+             (VOID **)&SecPlatformInformation2Ppi // PPI\r
+             );\r
+  if (Status == EFI_NOT_FOUND) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Get the size of the sec platform information2(BSP/APs' BIST data)\r
+    //\r
+    InformationSize         = 0;\r
+    SecPlatformInformation2 = NULL;\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
+                 );\r
+      if (Status == EFI_SUCCESS) {\r
+        //\r
+        // Retrieve BIST data\r
+        //\r
+        Status = SecPlatformInformation2Ppi->PlatformInformation2 (\r
+                                               PeiServices,\r
+                                               &InformationSize,\r
+                                               SecPlatformInformation2\r
+                                               );\r
+        if (Status == EFI_SUCCESS) {\r
+          *BistInformationData = SecPlatformInformation2;\r
+          if (BistInformationSize != NULL) {\r
+            *BistInformationSize = InformationSize;\r
+          }\r
+          return EFI_SUCCESS;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return EFI_DEVICE_ERROR;\r
+}\r
index 4e598cbfff592a5ef7af7991eae6ef1f750ab195..e875cffd5cd26c111899549f4b95fcce30d4aeac 100644 (file)
@@ -37,6 +37,7 @@
   SecMain.c\r
   SecMain.h\r
   FindPeiCore.c\r
+  SecBist.c\r
 \r
 [Sources.IA32]\r
   Ia32/ResetVec.nasmb\r
@@ -58,6 +59,9 @@
   PeCoffExtraActionLib\r
   CpuExceptionHandlerLib\r
   ReportStatusCodeLib\r
+  PeiServicesLib\r
+  PeiServicesTablePointerLib\r
+  HobLib\r
 \r
 [Ppis]\r
   gEfiSecPlatformInformationPpiGuid                    ## PRODUCES\r
index 05175d299d6d85cf41d18339b9c81d5383a6ca64..2484a0f05a71c24f3e9b0d15efa43cede90370cf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Master header file for SecCore.\r
 \r
-  Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2016, 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
@@ -18,6 +18,7 @@
 #include <PiPei.h>\r
 \r
 #include <Ppi/SecPlatformInformation.h>\r
+#include <Ppi/SecPlatformInformation2.h>\r
 #include <Ppi/TemporaryRamDone.h>\r
 \r
 #include <Library/BaseLib.h>\r
@@ -31,7 +32,9 @@
 #include <Library/DebugAgentLib.h>\r
 #include <Library/CpuExceptionHandlerLib.h>\r
 #include <Library/ReportStatusCodeLib.h>\r
-\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
 \r
 #define SEC_IDT_ENTRY_COUNT  34\r
 \r
index d4a6673770a193d5bc3e24a68d0c385b60fcddfc..bfe0fbdfdd114dae814546dc82ef000654737a7c 100644 (file)
@@ -65,6 +65,9 @@
 [LibraryClasses.common.SEC]\r
   PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf\r
   CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf\r
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
+  PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
+  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
 \r
 [LibraryClasses.common.PEIM]\r
   MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r